[Python-modules-commits] [python-mplexporter] 56/135: export legend

Wolfgang Borgert debacle at moszumanska.debian.org
Tue Sep 23 21:19:03 UTC 2014


This is an automated email from the git hooks/post-receive script.

debacle pushed a commit to branch master
in repository python-mplexporter.

commit fe79789b599a9583564ddce108f8f37da4acdaa7
Author: Jake Vanderplas <vanderplas at astro.washington.edu>
Date:   Wed Feb 26 11:08:01 2014 -0800

    export legend
---
 mplexporter/exporter.py | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/mplexporter/exporter.py b/mplexporter/exporter.py
index 64018e9..94657d0 100644
--- a/mplexporter/exporter.py
+++ b/mplexporter/exporter.py
@@ -4,6 +4,7 @@ Matplotlib Exporter
 This submodule contains tools for crawling a matplotlib figure and exporting
 relevant pieces to a renderer.
 """
+import warnings
 import io
 from . import utils
 
@@ -118,6 +119,22 @@ class Exporter(object):
                 self.draw_collection(ax, collection)
             for image in ax.images:
                 self.draw_image(ax, image)
+            if ax.legend_ is not None:
+                for child in ax.legend_.get_children()[:-1]:
+                    if isinstance(child, matplotlib.patches.Patch):
+                        self.draw_patch(ax, child)
+                for child in ax.legend_.get_children():
+                    if isinstance(child, matplotlib.text.Text):
+                        if not (child is ax.legend_.get_children()[-1]
+                                and child.get_text() == 'None'):
+                            self.draw_text(ax, child)
+                    elif isinstance(child, matplotlib.patches.Patch):
+                        pass
+                    elif isinstance(child, matplotlib.lines.Line2D):
+                        self.draw_line(ax, child)
+                    else:
+                        warnings.warn("Ignoring legend element: "
+                                      "{0}".format(child))
                 
 
     def draw_line(self, ax, line):

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/python-modules/packages/python-mplexporter.git



More information about the Python-modules-commits mailing list