Revision: 6316
          http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6316&view=rev
Author:   efiring
Date:     2008-10-24 06:51:29 +0000 (Fri, 24 Oct 2008)

Log Message:
-----------
Make shared axes work better with constrained aspect ratio.
This is restricted to the case of adjustable=datalim, and is
experimental.

Modified Paths:
--------------
    trunk/matplotlib/lib/matplotlib/axes.py

Modified: trunk/matplotlib/lib/matplotlib/axes.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/axes.py     2008-10-24 00:08:58 UTC (rev 
6315)
+++ trunk/matplotlib/lib/matplotlib/axes.py     2008-10-24 06:51:29 UTC (rev 
6316)
@@ -499,15 +499,24 @@
         self._originalPosition = self._position.frozen()
         self.set_axes(self)
         self.set_aspect('auto')
-        self.set_adjustable('box')
+        self._adjustable = 'box'
         self.set_anchor('C')
         self._sharex = sharex
         self._sharey = sharey
         if sharex is not None:
             self._shared_x_axes.join(self, sharex)
+            if sharex._adjustable == 'box':
+                sharex._adjustable = 'datalim'
+                #warnings.warn(
+                #    'shared axes: "adjustable" is being changed to "datalim"')
+            self._adjustable = 'datalim'
         if sharey is not None:
             self._shared_y_axes.join(self, sharey)
-
+            if sharex._adjustable == 'box':
+                sharex._adjustable = 'datalim'
+                #warnings.warn(
+                #    'shared axes: "adjustable" is being changed to "datalim"')
+            self._adjustable = 'datalim'
         self.set_label(label)
         self.set_figure(fig)
 
@@ -772,6 +781,11 @@
         if which in ('both', 'original'):
             self._originalPosition.set(pos)
 
+    def reset_position(self):
+        'Make the original position the active position'
+        pos = self.get_position(original=True)
+        self.set_position(pos, which='active')
+
     def _set_artist_props(self, a):
         'set the boilerplate props for artists added to axes'
         a.set_figure(self.figure)
@@ -992,6 +1006,10 @@
         ACCEPTS: [ 'box' | 'datalim' ]
         """
         if adjustable in ('box', 'datalim'):
+            if self in self._shared_x_axes or self in self._shared_y_axes:
+                if adjustable == 'box':
+                    raise ValueError(
+                        'adjustable must be "datalim" for shared axes')
             self._adjustable = adjustable
         else:
             raise ValueError('argument must be "box", or "datalim"')
@@ -1043,11 +1061,11 @@
         axes box or the view limits.
         '''
         if position is None:
-            position = self.get_position(True)
+            position = self.get_position(original=True)
 
         aspect = self.get_aspect()
         if aspect == 'auto':
-            self.set_position( position , 'active')
+            self.set_position( position , which='active')
             return
 
         if aspect == 'equal':
@@ -1058,7 +1076,10 @@
         #Ensure at drawing time that any Axes involved in axis-sharing
         # does not have its position changed.
         if self in self._shared_x_axes or self in self._shared_y_axes:
-            self._adjustable = 'datalim'
+            if self._adjustable == 'box':
+                self._adjustable = 'datalim'
+                warnings.warn(
+                    'shared axes: "adjustable" is being changed to "datalim"')
 
         figW,figH = self.get_figure().get_size_inches()
         fig_aspect = figH/figW
@@ -1069,6 +1090,10 @@
             self.set_position(pb1.anchored(self.get_anchor(), pb), 'active')
             return
 
+        # reset active to original in case it had been changed
+        # by prior use of 'box'
+        self.set_position(position, which='active')
+
         xmin,xmax = self.get_xbound()
         xsize = max(math.fabs(xmax-xmin), 1e-30)
         ymin,ymax = self.get_ybound()
@@ -1489,7 +1514,7 @@
         if not self.get_visible(): return
         renderer.open_group('axes')
 
-        self.apply_aspect(self.get_position(True))
+        self.apply_aspect()
 
         # the patch draws the background rectangle -- the frame below
         # will draw the edges


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

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Matplotlib-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-checkins

Reply via email to