[Yt-svn] yt-commit r492 - in trunk/yt: raven reason
mturk at wrangler.dreamhost.com
mturk at wrangler.dreamhost.com
Sun May 18 21:39:41 PDT 2008
Author: mturk
Date: Sun May 18 21:39:40 2008
New Revision: 492
URL: http://yt.spacepope.org/changeset/492
Log:
Added log/unlog for phase plots.
Modified:
trunk/yt/raven/PlotTypes.py
trunk/yt/reason/Notebook.py
Modified: trunk/yt/raven/PlotTypes.py
==============================================================================
--- trunk/yt/raven/PlotTypes.py (original)
+++ trunk/yt/raven/PlotTypes.py Sun May 18 21:39:40 2008
@@ -659,6 +659,19 @@
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_log_field(self, val):
+ if val:
+ self._log_z = True
+ self.norm = matplotlib.colors.LogNorm()
+ ttype = matplotlib.ticker.LogFormatter
+ else:
+ self._log_z = False
+ self.norm = matplotlib.colors.Normalize()
+ ttype = matplotlib.ticker.ScalarFormatter
+ if self.colorbar:
+ self.colorbar.set_norm(self.norm)
+ self.colorbar.formatter = ttype()
+
def _redraw_image(self):
vals = self.data[self.fields[2]].transpose()
used_bin = self.data["UsedBins"].transpose()
@@ -670,11 +683,16 @@
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)))
else:
self.norm=matplotlib.colors.Normalize(vmin=vmin, vmax=vmax,
clip=False)
self.ticker = matplotlib.ticker.MaxNLocator()
self.colorbar.set_norm(self.norm)
+ self.colorbar.set_norm(self.norm)
if self.cmap == None:
self.cmap = matplotlib.cm.get_cmap()
self.cmap.set_bad("w")
Modified: trunk/yt/reason/Notebook.py
==============================================================================
--- trunk/yt/reason/Notebook.py (original)
+++ trunk/yt/reason/Notebook.py Sun May 18 21:39:40 2008
@@ -669,6 +669,14 @@
self.Bind(wx.EVT_BUTTON, self.AddField, self.add_field)
self.Bind(wx.EVT_CHOICE, self.switch_z, self.z_field)
+ def SetupMenu(self):
+ PlotPage.SetupMenu(self)
+ self.popupmenu.AppendSeparator()
+ self.take_log_menu = self.popupmenu.AppendCheckItem(-1, "Take Log")
+ self.take_log_menu.Check(self.plot._log_z)
+
+ self.Bind(wx.EVT_MENU, self.take_log, self.take_log_menu)
+
def DoLayout(self):
self.MainSizer = wx.BoxSizer(wx.VERTICAL)
self.MainSizer.Add(self.figure_canvas, 1, wx.EXPAND)
@@ -738,6 +746,10 @@
fields.append(field)
return fields
+ def take_log(self, event):
+ self.plot.set_log_field(self.take_log_menu.IsChecked())
+ self.UpdateCanvas()
+
def switch_z(self, event=None):
if self.plot is None: return
self.plot.switch_z(self.z_field.GetStringSelection())
More information about the yt-svn
mailing list