[yt-svn] commit/yt: 2 new changesets

Bitbucket commits-noreply at bitbucket.org
Tue Jul 31 15:39:54 PDT 2012


2 new commits in yt:


https://bitbucket.org/yt_analysis/yt/changeset/05e80535a13b/
changeset:   05e80535a13b
branch:      yt
user:        samskillman
date:        2012-07-31 22:52:18
summary:     Adding more support for non-square plot windows.  This introduces an aspect calculation.  In addition, send the bbox_inches='tight' keyword in to the canvase.print_figure command to tighten up the whitespace surrounding all of the axes/labels.
affected #:  1 file

diff -r 57cc32755e03015f25047e14a6df678f73f58a49 -r 05e80535a13b4a6def60a87e51772653e45b857b yt/visualization/plot_window.py
--- a/yt/visualization/plot_window.py
+++ b/yt/visualization/plot_window.py
@@ -522,7 +522,7 @@
             xc, yc, zc = -999, -999, -999
         else:
             center[x_dict[self._frb.axis]] = 0.5 * (
-                self.xlim[0] + self.xlim[1])
+                self.xlim[1] + self.xlim[1])
             center[y_dict[self._frb.axis]] = 0.5 * (
                 self.ylim[0] + self.ylim[1])
             xc, yc, zc = center
@@ -588,7 +588,7 @@
             else:
                 raise RuntimeError(
                     'origin keyword: \"%(k)s\" not recognized' % {'k': self.origin})
-            
+
             extent = [self.xlim[i] - xc for i in (0,1)]
             extent.extend([self.ylim[i] - yc for i in (0,1)])
             extent = [el*self.pf[md['unit']] for el in extent]
@@ -598,8 +598,14 @@
             else:
                 zlim = (None,None)
 
-            #Hardcoding this for now.
-            size = (9,8)
+            aspect = (self.xlim[1] - self.xlim[0])/(self.ylim[1]-self.ylim[0])
+
+            # This sets the size of the figure, and defaults to making one of the dimensions smaller.
+            # This should protect against giant images in the case of a very large aspect ratio.
+            if aspect > 1.0:
+                size = (10.0, 10.0/aspect)
+            else:
+                size = (10.0*aspect, 10.0)
 
             self.plots[f] = WindowPlotMPL(self._frb[f], extent, self._field_transform[f], 
                                           self._colormaps[f], size, zlim)
@@ -1057,7 +1063,7 @@
         self.figure = matplotlib.figure.Figure(figsize = size, frameon = True)
         # Hardcoding the axis dimensions for now
         self.axes = self.figure.add_axes((.07,.10,.8,.8))
-        self.cax = self.figure.add_axes((.86,.10,.04,.8))
+        self.cax = self.figure.add_axes((.87,.10,.04,.8))
 
     def save(self, name, canvas = None):
         if name[-4:] == '.png':
@@ -1076,7 +1082,7 @@
             else:
                 mylog.warning("Unknown suffix %s, defaulting to Agg", suffix)
                 canvas = FigureCanvasAgg(self.figure)
-        canvas.print_figure(fn)
+        canvas.print_figure(fn, bbox_inches='tight')
         return fn
 
     def _repr_png_(self):



https://bitbucket.org/yt_analysis/yt/changeset/5017b64cb6fd/
changeset:   5017b64cb6fd
branch:      yt
user:        samskillman
date:        2012-07-31 23:01:36
summary:     I'm not sure how that got there.
affected #:  1 file

diff -r 05e80535a13b4a6def60a87e51772653e45b857b -r 5017b64cb6fd1518466dc56cdc56ad4f34d6e943 yt/visualization/plot_window.py
--- a/yt/visualization/plot_window.py
+++ b/yt/visualization/plot_window.py
@@ -522,7 +522,7 @@
             xc, yc, zc = -999, -999, -999
         else:
             center[x_dict[self._frb.axis]] = 0.5 * (
-                self.xlim[1] + self.xlim[1])
+                self.xlim[0] + self.xlim[1])
             center[y_dict[self._frb.axis]] = 0.5 * (
                 self.ylim[0] + self.ylim[1])
             xc, yc, zc = center

Repository URL: https://bitbucket.org/yt_analysis/yt/

--

This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.



More information about the yt-svn mailing list