[Yt-svn] yt-commit r508 - in trunk/yt: raven reason

mturk at wrangler.dreamhost.com mturk at wrangler.dreamhost.com
Thu May 29 22:40:19 PDT 2008


Author: mturk
Date: Thu May 29 22:40:17 2008
New Revision: 508
URL: http://yt.spacepope.org/changeset/508

Log:
I figured out how to get the array to be updated without calling _redraw_image.
For the longest time I couldn't get it to update the figure canvas correctly,
so you'd end up with some output that was half-size.  The key thing I had to do
was re-set the *xlim* -- the AxesImage object had the correct extent, but the
xlim on the current Axes object was set to the current viewport as viewed from
the old coordinates.

So that's fixed, and I can close #97.

Unfortunately now I can't seem to figure out how to get the legend to update
quite correctly if you're in mathtext mode.



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	Thu May 29 22:40:17 2008
@@ -242,10 +242,13 @@
             self.colorbar = None
         self.set_width(1,'1')
 
-    def _get_buff(self):
+    def _get_buff(self, width=None):
         x0, x1 = self.xlim
         y0, y1 = self.ylim
-        l, b, width, height = self._axes.bbox.get_bounds()
+        if width is None:
+            l, b, width, height = self._axes.bbox.get_bounds()
+        else:
+            height = width
         self.pix = (width,height)
         # 'px' == pixel x, or x in the plane of the slice
         # 'x' == actual x
@@ -390,11 +393,16 @@
         if self.colorbar != None: self.colorbar.set_label(str(data_label))
 
 class CuttingPlanePlot(SlicePlot):
+
     _type_name = "CuttingPlane"
-    def _get_buff(self):
+
+    def _get_buff(self, width=None):
         px_min, px_max = self.xlim
         py_min, py_max = self.ylim
-        l, b, width, height = self._axes.bbox.get_bounds()
+        if width is None:
+            l, b, width, height = self._axes.bbox.get_bounds()
+        else:
+            height = width
         self.pix = (width,height)
         indices = na.argsort(self.data['dx'])[::-1]
         buff = _MPL.CPixelize( self.data['x'], self.data['y'], self.data['z'],

Modified: trunk/yt/reason/Notebook.py
==============================================================================
--- trunk/yt/reason/Notebook.py	(original)
+++ trunk/yt/reason/Notebook.py	Thu May 29 22:40:17 2008
@@ -324,8 +324,18 @@
             path = dlg.GetPath()
             orig_size = self.figure.get_size_inches()
             self.figure.set_size_inches((10,8))
-            self.figure_canvas.print_figure(path,format='png')
+            width = self.figure.get_dpi()*8.0
+            buff = self.plot._get_buff(width=width)
+            self.plot._axes.images[0].set_data(buff)
+            self.plot._axes.set_xlim(-0.5,width-0.5)
+            self.plot._axes.set_ylim(-0.5,width-0.5)
+            self.UpdateCanvas(only_fig=True)
+            self.figure_canvas.print_figure(path,format='png',
+                                            dpi=self.figure.get_dpi())
+            # We leave the higher-resolution buffer in there
+            self.figure.savefig(path,format='png')
             self.figure.set_size_inches(orig_size)
+            self.UpdateCanvas(only_fig=True)
         dlg.Destroy()
 
     def SetupFigure(self):



More information about the yt-svn mailing list