[yt-svn] commit/yt: MatthewTurk: Updating plot window to work from command line again. Removing pyplot imports.
Bitbucket
commits-noreply at bitbucket.org
Mon Jul 23 14:33:09 PDT 2012
1 new commit in yt:
https://bitbucket.org/yt_analysis/yt/changeset/496560a606e7/
changeset: 496560a606e7
branch: yt
user: MatthewTurk
date: 2012-07-23 23:24:32
summary: Updating plot window to work from command line again. Removing pyplot imports.
Adding ._mpl_imports to plot_window.py.
affected #: 2 files
diff -r 23b48bc0af3527e11b6f95df9dcd490f90a35a09 -r 496560a606e77c99a6ef69053725de63c38bd8b8 yt/utilities/command_line.py
--- a/yt/utilities/command_line.py
+++ b/yt/utilities/command_line.py
@@ -1140,11 +1140,11 @@
unit = args.unit
if unit is None:
- unit = '1'
- width = args.width
- if width is None:
- width = 0.5*(pf.domain_right_edge - pf.domain_left_edge)
- width /= pf[unit]
+ unit = 'unitary'
+ if args.width is None:
+ width = (1.0, 'unitary')
+ else:
+ width = (args.width, args.unit)
for ax in axes:
mylog.info("Adding plot for axis %i", ax)
diff -r 23b48bc0af3527e11b6f95df9dcd490f90a35a09 -r 496560a606e77c99a6ef69053725de63c38bd8b8 yt/visualization/plot_window.py
--- a/yt/visualization/plot_window.py
+++ b/yt/visualization/plot_window.py
@@ -25,7 +25,7 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
"""
import base64
-import matplotlib.pyplot
+import matplotlib.figure
import cStringIO
import types
from functools import wraps
@@ -41,6 +41,7 @@
callback_registry
from .tick_locators import LogLocator, LinearLocator
from yt.utilities.delaunay.triangulate import Triangulation as triang
+from ._mpl_imports import *
from yt.funcs import *
from yt.utilities.lib import write_png_to_string
@@ -595,8 +596,8 @@
self.plots[f] = WindowPlotMPL(self._frb[f], extent, self._field_transform[f],
self._colormaps[f], size, zlim)
- self.plots[f].cb = \
- matplotlib.pyplot.colorbar(self.plots[f].image,cax = self.plots[f].cax)
+ self.plots[f].cb = self.plots[f].figure.colorbar(
+ self.plots[f].image, cax = self.plots[f].cax)
if self.oblique == False:
labels = [r'$\rm{'+axis_labels[axis_index][i].encode('string-escape')+
@@ -884,8 +885,6 @@
if self._contour_info is None and self._vector_info is None:
return write_png_to_string(img)
from matplotlib.figure import Figure
- from yt.visualization._mpl_imports import \
- FigureCanvasAgg, FigureCanvasPdf, FigureCanvasPS
vi, vj, vn = img.shape
@@ -1006,18 +1005,29 @@
figure = None
def __init__(self, field, size):
self._plot_valid = True
- self.figure = matplotlib.pyplot.figure(figsize=size,frameon=True)
+ self.figure = matplotlib.figure.Figure(figsize = size, frameon = True)
# Hardcoding the axis dimensions for now
self.axes = self.figure.add_axes((.07,.10,.8,.8))
self.cax = self.figure.add_axes((.86,.10,.04,.8))
- def save(self,name):
+ def save(self, name, canvas = None):
if name[-4:] == '.png':
suffix = ''
else:
suffix = '.png'
- print "saving plot %s"%name+suffix
- self.figure.savefig('%s'%name+suffix)
+ fn = "%s%s" % (name, suffix)
+ mylog.info("Saving plot %s", fn)
+ if canvas is None:
+ if suffix == ".png":
+ canvas = FigureCanvasAgg(self.figure)
+ elif suffix == ".pdf":
+ canvas = FigureCanvasPdf(self.figure)
+ elif suffix in (".eps", ".ps"):
+ canvas = FigureCanvasPS
+ else:
+ mylog.warning("Unknown suffix %s, defaulting to Agg", suffix)
+ canvas = FigureCanvasAgg(self.figure)
+ canvas.print_figure(fn)
class WindowPlotMPL(PlotMPL):
def __init__(self, data, extent, field_transform, cmap, size, zlim):
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