[Yt-svn] yt-commit r1130 - branches/yt-1.0/yt/raven

mturk at wrangler.dreamhost.com mturk at wrangler.dreamhost.com
Tue Jan 20 08:43:19 PST 2009


Author: mturk
Date: Tue Jan 20 08:43:19 2009
New Revision: 1130
URL: http://yt.spacepope.org/changeset/1130

Log:
Backport a fix to get the PhasePlot zlim working correctly



Modified:
   branches/yt-1.0/yt/raven/PlotTypes.py

Modified: branches/yt-1.0/yt/raven/PlotTypes.py
==============================================================================
--- branches/yt-1.0/yt/raven/PlotTypes.py	(original)
+++ branches/yt-1.0/yt/raven/PlotTypes.py	Tue Jan 20 08:43:19 2009
@@ -559,6 +559,8 @@
 class PhasePlot(ProfilePlot):
 
     _type_name = "Profile2D"
+    _xlim = None
+    _ylim = None
     def __init__(self, data, fields, id, ticker=None, cmap=None,
                  figure=None, axes=None):
         self._semi_unique_id = id
@@ -566,6 +568,7 @@
         self.ticker = ticker
         self.image = None
         self.set_cmap(cmap)
+        self._zlim = None
 
         self.axis_names["X"] = fields[0]
         self.axis_names["Y"] = fields[1]
@@ -599,6 +602,18 @@
         if field not in self.data.keys(): self.data.add_fields(field, weight, accumulation)
         self._log_z = self.setup_bins(self.fields[2])
 
+    def set_xlim(self, xmin, xmax):
+        self._xlim = (xmin,xmax)
+
+    def set_ylim(self, ymin, ymax):
+        self._ylim = (ymin,ymax)
+
+    def set_zlim(self, zmin, zmax):
+        """
+        Set the z boundaries of this plot.
+        """
+        self._zlim = (zmin, zmax)
+
     def set_log_field(self, val):
         if val:
             self._log_z = True
@@ -617,15 +632,17 @@
         used_bin = self.data["UsedBins"].transpose()
         vmin = na.nanmin(vals[used_bin])
         vmax = na.nanmax(vals[used_bin])
+        if self._zlim is not None: vmin, vmax = self._zlim
         if self._log_z:
             # We want smallest non-zero vmin
             self.norm=matplotlib.colors.LogNorm(vmin=vmin, vmax=vmax,
                                                 clip=False)
             self.ticker = matplotlib.ticker.LogLocator()
-            vI = na.where(vals > 0)
-            newmin = vals[vI].min()
-            newmax = vals[vI].max()
-            self.norm.autoscale(na.array((newmin,newmax)))
+            if self._zlim is None:
+                vI = na.where(vals > 0)
+                vmin = vals[vI].min()
+                vmax = vals[vI].max()
+            self.norm.autoscale(na.array((vmin,vmax)))
         else:
             self.norm=matplotlib.colors.Normalize(vmin=vmin, vmax=vmax,
                                                   clip=False)
@@ -644,6 +661,8 @@
                                       norm=self.norm, cmap=self.cmap)
         self._axes.set_xscale({0:"linear",1:"log"}[int(self._log_x)])
         self._axes.set_yscale({0:"linear",1:"log"}[int(self._log_y)])
+        if self._xlim is not None: self._axes.set_xlim(*self._xlim)
+        if self._ylim is not None: self._axes.set_ylim(*self._ylim)
         self.vals = vals
 
         _notify(self.image, self.colorbar)



More information about the yt-svn mailing list