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

dcollins at wrangler.dreamhost.com dcollins at wrangler.dreamhost.com
Wed Sep 23 15:22:02 PDT 2009


Author: dcollins
Date: Wed Sep 23 15:22:00 2009
New Revision: 1458
URL: http://yt.spacepope.org/changeset/1458

Log:
Added *annotate* keyword to GridBoundaryCallback: prints grid id number to corner of grid

Modified:
   trunk/yt/raven/Callbacks.py

Modified: trunk/yt/raven/Callbacks.py
==============================================================================
--- trunk/yt/raven/Callbacks.py	(original)
+++ trunk/yt/raven/Callbacks.py	Wed Sep 23 15:22:00 2009
@@ -189,15 +189,16 @@
 
 class GridBoundaryCallback(PlotCallback):
     _type_name = "grids"
-    def __init__(self, alpha=1.0, min_pix = 1):
+    def __init__(self, alpha=1.0, min_pix = 1,annotate=False):
         """
         Adds grid boundaries to a plot, optionally with *alpha*-blending.
         Cuttoff for display is at *min_pix* wide.
+        *annotate* puts the grid id in the corner of the grid.  (Not so great in projections...)
         """
         PlotCallback.__init__(self)
         self.alpha = alpha
         self.min_pix = min_pix
-
+        self.annotate=annotate # put grid numbers in the corner.        
     def __call__(self, plot):
         x0, x1 = plot.xlim
         y0, y1 = plot.ylim
@@ -231,6 +232,10 @@
                            edgecolors=edgecolors)
             plot._axes.hold(True)
             plot._axes.add_collection(grid_collection)
+            if self.annotate:
+                ids = [g.id for g in plot.data._grids]
+                for n in range(len(left_edge_px)):
+                    plot._axes.text(left_edge_px[n]+2,left_edge_py[n]+2,ids[n])
             plot._axes.hold(False)
 
 class LabelCallback(PlotCallback):



More information about the yt-svn mailing list