[Yt-svn] commit/yt: MatthewTurk: Adding a to_mpl method to the profile plotter. Much more convenient.
Bitbucket
commits-noreply at bitbucket.org
Mon May 23 11:38:59 PDT 2011
1 new changeset in yt:
http://bitbucket.org/yt_analysis/yt/changeset/f8d1ca7f701c/
changeset: r4276:f8d1ca7f701c
branch: yt
user: MatthewTurk
date: 2011-05-23 20:37:44
summary: Adding a to_mpl method to the profile plotter. Much more convenient.
affected #: 1 file (1.2 KB)
--- a/yt/visualization/profile_plotter.py Mon May 23 14:25:58 2011 -0400
+++ b/yt/visualization/profile_plotter.py Mon May 23 14:37:44 2011 -0400
@@ -67,6 +67,41 @@
class PlotContainer(object):
x_spec = None
y_spec = None
+ x_values = None
+ y_values = None
+ plot_spec = None
+
+ def to_mpl(self, place = None):
+ import _mpl_imports as mpl
+ if isinstance(place, mpl.matplotlib.figure.Figure):
+ figure, place = place, None
+ place = None
+ else:
+ figure = mpl.matplotlib.figure.Figure((10,8))
+ if isinstance(place, mpl.matplotlib.axes.Axes):
+ axes, place = place, None
+ else:
+ axes = figure.add_subplot(1,1,1)
+ if self.x_spec.scale == 'log' and \
+ self.y_spec.scale == 'log':
+ func = axes.loglog
+ elif self.x_spec == 'log':
+ func = axes.semilogx
+ elif self.y_spec == 'log':
+ func = axes.semilogy
+ if self.plot_spec is None:
+ kwargs = {}
+ else:
+ kwargs = self.plot_spec
+ func(self.x_values, self.y_values, **kwargs)
+ if self.x_spec.title is not None:
+ axes.set_xlabel(self.x_spec.title)
+ if self.y_spec.title is not None:
+ axes.set_ylabel(self.y_spec.title)
+ if isinstance(place, types.StringTypes):
+ canvas = mpl.FigureCanvasAgg(figure)
+ canvas.print_figure(place)
+ return figure, axes
class ImagePlotContainer(object):
x_spec = None
Repository URL: https://bitbucket.org/yt_analysis/yt/
--
This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.
More information about the yt-svn
mailing list