[Python-modules-commits] [python-mplexporter] 17/135: add savefig command to correctly place text
Wolfgang Borgert
debacle at moszumanska.debian.org
Tue Sep 23 21:18:59 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 92e504fe3833e51a87669f7ff50c6953f84d7f97
Author: Jake Vanderplas <vanderplas at astro.washington.edu>
Date: Wed Feb 19 12:39:59 2014 -0800
add savefig command to correctly place text
---
.gitignore | 5 ++++-
mplexporter/exporter.py | 11 ++++++++---
2 files changed, 12 insertions(+), 4 deletions(-)
diff --git a/.gitignore b/.gitignore
index 43ac30c..0e51aba 100644
--- a/.gitignore
+++ b/.gitignore
@@ -37,4 +37,7 @@ nosetests.xml
# emacs backup files
-*~
\ No newline at end of file
+*~
+
+# ipython backups
+.ipynb_checkpoints
diff --git a/mplexporter/exporter.py b/mplexporter/exporter.py
index d918f5b..4586d4b 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 io
from . import utils
@@ -26,12 +27,16 @@ class Exporter(object):
self.renderer = renderer
def run(self, fig):
+ # Calling savefig executes the draw() command, putting elements
+ # in the correct place.
+ fig.savefig(io.BytesIO(), format='png', dpi=fig.dpi)
if self.close_mpl:
import matplotlib.pyplot as plt
plt.close(fig)
self._crawl_fig(fig)
- def _process_transform(self, transform, ax=None, data=None):
+ @staticmethod
+ def _process_transform(transform, ax=None, data=None):
"""Process the transform and convert data to figure or data coordinates
Parameters
@@ -109,9 +114,9 @@ class Exporter(object):
for text in ax.texts:
# xlabel and ylabel are passed as arguments to the axes
# we don't want to pass them again here
- if text is ax.get_xlabel():
+ if text is ax.xaxis.label:
continue
- if text is ax.get_ylabel():
+ if text is ax.yaxis.label:
continue
content = text.get_text()
--
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