[Yt-svn] yt-commit r1336 - trunk/yt/raven
skillman at wrangler.dreamhost.com
skillman at wrangler.dreamhost.com
Tue Jun 16 08:36:26 PDT 2009
Author: skillman
Date: Tue Jun 16 08:36:25 2009
New Revision: 1336
URL: http://yt.spacepope.org/changeset/1336
Log:
Updating PlotCollection set_zlim function so that users can now specify limits based off min or max values in plot.
Example: Set max to be max value, go 3 orders of magnitude down:
pc.set_zlim(None,'max',dex=3)
If the true range is less than 10^3, the minimum is taken from the minimum value. This should help with plots that have large ranges.
Modified:
trunk/yt/raven/PlotCollection.py
trunk/yt/raven/PlotTypes.py
Modified: trunk/yt/raven/PlotCollection.py
==============================================================================
--- trunk/yt/raven/PlotCollection.py (original)
+++ trunk/yt/raven/PlotCollection.py Tue Jun 16 08:36:25 2009
@@ -102,13 +102,16 @@
for plot in self.plots:
plot.set_ylim(ymin, ymax)
- def set_zlim(self, zmin, zmax):
+ def set_zlim(self, zmin, zmax,dex=None):
"""
- Set the limits of the colorbar.
+ Set the limits of the colorbar. 'min' or 'max' are possible inputs
+ when combined with dex=value, where value gives the maximum number of
+ dex to go above/below the min/max. If value is larger than the true
+ range of values, min/max are limited to true range.
"""
for plot in self.plots:
plot.set_autoscale(False)
- plot.set_zlim(zmin, zmax)
+ plot.set_zlim(zmin, zmax, dex=dex)
def set_lim(self, lim):
"""
Modified: trunk/yt/raven/PlotTypes.py
==============================================================================
--- trunk/yt/raven/PlotTypes.py (original)
+++ trunk/yt/raven/PlotTypes.py Tue Jun 16 08:36:25 2009
@@ -138,12 +138,21 @@
"""
self._axes.set_ylim(ymin, ymax)
- def set_zlim(self, zmin, zmax):
+ def set_zlim(self, zmin, zmax, dex=None):
"""
Set the z boundaries of this plot.
"""
# This next call fixes some things, but is slower...
#self._redraw_image()
+ if (zmin is None) or (zmax is None):
+ if zmin == 'min':
+ zmin = na.nanmin(self._axes.images[-1]._A)
+ if dex is not None:
+ zmax = min(zmin*10**(dex),na.nanmax(self._axes.images[-1]._A))
+ if zmax == 'max':
+ zmax = na.nanmax(self._axes.images[-1]._A)
+ if dex is not None:
+ zmin = max(zmax/(10**(dex)),na.nanmin(self._axes.images[-1]._A))
self.norm.autoscale(na.array([zmin,zmax]))
self.image.changed()
if self.colorbar is not None:
@@ -730,10 +739,21 @@
def set_ylim(self, ymin, ymax):
self._ylim = (ymin,ymax)
- def set_zlim(self, zmin, zmax):
+ def set_zlim(self, zmin, zmax, dex=None):
"""
Set the z boundaries of this plot.
"""
+ # This next call fixes some things, but is slower...
+ #self._redraw_image()
+ if (zmin is None) or (zmax is None):
+ if zmin == 'min':
+ zmin = na.nanmin(self._axes.images[-1]._A)
+ if dex is not None:
+ zmax = min(zmin*10**(dex),na.nanmax(self._axes.images[-1]._A))
+ if zmax == 'max':
+ zmax = na.nanmax(self._axes.images[-1]._A)
+ if dex is not None:
+ zmin = max(zmax/(10**(dex)),na.nanmin(self._axes.images[-1]._A))
self._zlim = (zmin, zmax)
def set_log_field(self, val):
More information about the yt-svn
mailing list