[Yt-svn] yt-commit r509 - trunk/yt/raven

mturk at wrangler.dreamhost.com mturk at wrangler.dreamhost.com
Thu May 29 23:12:11 PDT 2008


Author: mturk
Date: Thu May 29 23:12:10 2008
New Revision: 509
URL: http://yt.spacepope.org/changeset/509

Log:
Ugh, a bug in PlotCollections that was committed maybe yesterday that I haven't
seen until just now.  NewPhasePlot!  How did that one sneak by me?

Added the callback for lines overplotted on, well, just about anything.  It's
mostly/only useful for profiles, however, and then with some care.

Changed all the callbacks to be proper descendents of the PlotCallback class.

Added _run_callbacks for the phase plots.

This closes #74.



Modified:
   trunk/yt/raven/Callbacks.py
   trunk/yt/raven/PlotCollection.py
   trunk/yt/raven/PlotTypes.py

Modified: trunk/yt/raven/Callbacks.py
==============================================================================
--- trunk/yt/raven/Callbacks.py	(original)
+++ trunk/yt/raven/Callbacks.py	Thu May 29 23:12:10 2008
@@ -28,10 +28,12 @@
 import _MPL
 
 class PlotCallback(object):
-    pass
+    def __init__(self, *args, **kwargs):
+        pass
 
 class QuiverCallback(PlotCallback):
     def __init__(self, field_x, field_y, axis, factor):
+        PlotCallback.__init__(self)
         self.field_x = field_x
         self.field_y = field_y
         self.axis = axis
@@ -68,6 +70,7 @@
 
 class ParticleCallback(PlotCallback):
     def __init__(self, axis, width, p_size=1.0, col='k'):
+        PlotCallback.__init__(self)
         self.axis = axis
         self.width = width
         self.p_size = p_size
@@ -103,6 +106,7 @@
 
 class ContourCallback(PlotCallback):
     def __init__(self, field, ncont=5, factor=4, take_log=False, clim=None):
+        PlotCallback.__init__(self)
         self.factor = factor
         self.take_log = take_log
         try:
@@ -143,6 +147,7 @@
 
 class GridBoundaryCallback(PlotCallback):
     def __init__(self, alpha=1.0, min_pix = 1):
+        PlotCallback.__init__(self)
         self.alpha = alpha
         self.min_pix = min_pix
 
@@ -185,6 +190,7 @@
 
 class UnitBoundaryCallback(PlotCallback):
     def __init__(self, unit = "au", factor=4, text_annotate=True, text_which=-2):
+        PlotCallback.__init__(self)
         self.unit = unit
         self.factor = factor
         self.text_annotate = text_annotate
@@ -224,7 +230,7 @@
         verts=verts.transpose()[visible,:,:]
         grid_collection = matplotlib.collections.PolyCollection(
                 verts, facecolors=(0.0,0.0,0.0,0.0),
-                       edgecolors = (0.0,0.0,0.0,1.0),
+                       edgecolors=(0.0,0.0,0.0,1.0),
                        linewidths=2.5)
         plot._axes.hold(True)
         plot._axes.add_collection(grid_collection)
@@ -235,3 +241,16 @@
             w *= plot.data.pf[good_u]
             plot._axes.annotate("%0.3e %s" % (w,good_u), verts[ti,1,:]+5)
         plot._axes.hold(False)
+
+class LinePlotCallback(PlotCallback):
+    def __init__(self, x, y, plot_args = None):
+        PlotCallback.__init__(self)
+        self.x = x
+        self.y = y
+        if plot_args is None: plot_args = {}
+        self.plot_args = plot_args
+
+    def __call__(self, plot):
+        plot._axes.hold(True)
+        plot._axes.plot(self.x, self.y, **self.plot_args)
+        plot._axes.hold(False)

Modified: trunk/yt/raven/PlotCollection.py
==============================================================================
--- trunk/yt/raven/PlotCollection.py	(original)
+++ trunk/yt/raven/PlotCollection.py	Thu May 29 23:12:10 2008
@@ -169,8 +169,8 @@
         profile.pf = self.pf
         profile.hierarchy = self.pf.hierarchy
         if id is None: id = self._get_new_id()
-        p = self._add_plot(PlotTypes.NewPhasePlot(profile, fields, 
-                                                  id, cmap=cmap))
+        p = self._add_plot(PlotTypes.PhasePlot(profile, fields, 
+                                               id, cmap=cmap))
         return p
 
     def _get_new_id(self):

Modified: trunk/yt/raven/PlotTypes.py
==============================================================================
--- trunk/yt/raven/PlotTypes.py	(original)
+++ trunk/yt/raven/PlotTypes.py	Thu May 29 23:12:10 2008
@@ -545,6 +545,7 @@
         self.autoset_label(self.fields[0], self._axes.set_xlabel)
         self.autoset_label(self.fields[1], self._axes.set_ylabel)
         self.autoset_label(self.fields[2], self.colorbar.set_label)
+        self._run_callbacks()
 
     def _generate_prefix(self, prefix):
         self.prefix = "_".join([prefix, self._type_name,



More information about the yt-svn mailing list