Revision: 4615
          http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4615&view=rev
Author:   mdboom
Date:     2007-12-05 07:36:48 -0800 (Wed, 05 Dec 2007)

Log Message:
-----------
Make new auto-layout stuff optional (so it can be experimented on
without breaking too much.)

Modified Paths:
--------------
    branches/transforms/examples/simple_plot.py
    branches/transforms/lib/matplotlib/figure.py
    branches/transforms/lib/matplotlib/rcsetup.py

Modified: branches/transforms/examples/simple_plot.py
===================================================================
--- branches/transforms/examples/simple_plot.py 2007-12-05 15:16:48 UTC (rev 
4614)
+++ branches/transforms/examples/simple_plot.py 2007-12-05 15:36:48 UTC (rev 
4615)
@@ -13,9 +13,6 @@
 ylabel('voltage (mV)')
 title('About as simple as it gets, folks')
 grid(True)
-axes().xaxis.set_label_position('top')
-axes().xaxis.set_ticks_position('top')
-axes().yaxis.set_label_position('right')
 
 #savefig('simple_plot.png')
 savefig('simple_plot')

Modified: branches/transforms/lib/matplotlib/figure.py
===================================================================
--- branches/transforms/lib/matplotlib/figure.py        2007-12-05 15:16:48 UTC 
(rev 4614)
+++ branches/transforms/lib/matplotlib/figure.py        2007-12-05 15:36:48 UTC 
(rev 4615)
@@ -151,6 +151,7 @@
         self.clf()
 
         self._cachedRenderer = None
+        self._autoLayout = False
 
     def _get_dpi(self):
        return self._dpi
@@ -159,6 +160,9 @@
        self._dpi_scale_trans.clear().scale(dpi, dpi)
     dpi = property(_get_dpi, _set_dpi)
 
+    def enable_auto_layout(self, setting=True):
+        self._autoLayout = setting
+
     def autofmt_xdate(self, bottom=0.2, rotation=30, ha='right'):
         """
         A common use case is a number of subplots with shared xaxes
@@ -628,8 +632,9 @@
         # based on the tick and axis labels etc., and then makes sure
         # that any axes that began life aligned to another axes remains
         # aligned after these adjustments
-        if len(self.axes) > 1:
+        if self._autoLayout and len(self.axes) > 1:
             aligned_positions = [{}, {}, {}, {}]
+            sizes = [{}, {}]
             for a in self.axes:
                 a.update_layout(renderer)
                 orig_pos = a.get_position(True)
@@ -642,6 +647,15 @@
                         pos[orig][1].add(curr)
                     else:
                         pos[orig] = [[a], set([curr])]
+                for size, orig, curr in zip(sizes,
+                                            orig_pos.size,
+                                            curr_pos.size):
+                    orig = round(orig * 100.0) / 100.0
+                    if orig in size:
+                        size[orig][0].append(a)
+                        size[orig][1].add(curr)
+                    else:
+                        size[orig] = [[a], set([curr])]
 
             for i, pos in enumerate(aligned_positions):
                 for axes, places in pos.values():
@@ -654,7 +668,19 @@
                             curr_pos = a.get_position().frozen()
                             curr_pos.get_points()[i/2, i%2] = curr
                             a.set_position(curr_pos, 'active')
-        else:
+
+            for i, size in enumerate(sizes):
+                for axes, dims in size.values():
+                    new = min(dims)
+                    for a in axes:
+                        curr_pos = a.get_position().frozen()
+                        curr = curr_pos.size[i]
+                        if curr > new:
+                            extra = (curr - new) * 0.5
+                            curr_pos.get_points()[0, i] += extra
+                            curr_pos.get_points()[1, i] -= extra
+                            a.set_position(curr_pos, 'active')
+        elif self._autoLayout:
             for a in self.axes: a.update_layout(renderer)
 
         # render the axes

Modified: branches/transforms/lib/matplotlib/rcsetup.py
===================================================================
--- branches/transforms/lib/matplotlib/rcsetup.py       2007-12-05 15:16:48 UTC 
(rev 4614)
+++ branches/transforms/lib/matplotlib/rcsetup.py       2007-12-05 15:36:48 UTC 
(rev 4615)
@@ -440,12 +440,12 @@
     'figure.facecolor'  : [ '0.75', validate_color], # facecolor; scalar gray
     'figure.edgecolor'  : [ 'w', validate_color],  # edgecolor; white
 
-    'figure.subplot.left'   : [0.1, ValidateInterval(0, 1, closedmin=False, 
closedmax=False)],
+    'figure.subplot.left'   : [0.125, ValidateInterval(0, 1, closedmin=False, 
closedmax=False)],
     'figure.subplot.right'  : [0.9, ValidateInterval(0, 1, closedmin=False, 
closedmax=False)],
     'figure.subplot.bottom' : [0.1, ValidateInterval(0, 1, closedmin=False, 
closedmax=False)],
     'figure.subplot.top'    : [0.9, ValidateInterval(0, 1, closedmin=False, 
closedmax=False)],
-    'figure.subplot.wspace' : [0.1, ValidateInterval(0, 1, closedmin=False, 
closedmax=True)],
-    'figure.subplot.hspace' : [0.1, ValidateInterval(0, 1, closedmin=False, 
closedmax=True)],
+    'figure.subplot.wspace' : [0.2, ValidateInterval(0, 1, closedmin=False, 
closedmax=True)],
+    'figure.subplot.hspace' : [0.2, ValidateInterval(0, 1, closedmin=False, 
closedmax=True)],
 
 
     'savefig.dpi'         : [100, validate_float],   # DPI


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

-------------------------------------------------------------------------
SF.Net email is sponsored by: The Future of Linux Business White Paper
from Novell.  From the desktop to the data center, Linux is going
mainstream.  Let it simplify your IT future.
http://altfarm.mediaplex.com/ad/ck/8857-50307-18918-4
_______________________________________________
Matplotlib-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-checkins

Reply via email to