Revision: 6315
          http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6315&view=rev
Author:   efiring
Date:     2008-10-24 00:08:58 +0000 (Fri, 24 Oct 2008)

Log Message:
-----------
Support autoscaling with shared axes

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

Modified: trunk/matplotlib/CHANGELOG
===================================================================
--- trunk/matplotlib/CHANGELOG  2008-10-23 19:56:04 UTC (rev 6314)
+++ trunk/matplotlib/CHANGELOG  2008-10-24 00:08:58 UTC (rev 6315)
@@ -1,3 +1,5 @@
+2008-10-23 Autoscaling is now supported with shared axes - EF
+
 2008-10-23 Fixed exception in dviread that happened with Minion - JKS
 
 2008-10-21 set_xlim, ylim now return a copy of the viewlim array to

Modified: trunk/matplotlib/lib/matplotlib/axes.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/axes.py     2008-10-23 19:56:04 UTC (rev 
6314)
+++ trunk/matplotlib/lib/matplotlib/axes.py     2008-10-24 00:08:58 UTC (rev 
6315)
@@ -1451,20 +1451,30 @@
         """
         # if image data only just use the datalim
         if not self._autoscaleon: return
+        if scalex:
+            xshared = self._shared_x_axes.get_siblings(self)
+            dl = [ax.dataLim for ax in xshared]
+            bb = mtransforms.BboxBase.union(dl)
+            x0, x1 = bb.intervalx
+        if scaley:
+            yshared = self._shared_y_axes.get_siblings(self)
+            dl = [ax.dataLim for ax in yshared]
+            bb = mtransforms.BboxBase.union(dl)
+            y0, y1 = bb.intervaly
         if (tight or (len(self.images)>0 and
                       len(self.lines)==0 and
                       len(self.patches)==0)):
-
-            if scalex: self.set_xbound(self.dataLim.intervalx)
-
-            if scaley: self.set_ybound(self.dataLim.intervaly)
+            if scalex:
+                self.set_xbound(x0, x1)
+            if scaley:
+                self.set_ybound(y0, 11)
             return
 
         if scalex:
-            XL = self.xaxis.get_major_locator().autoscale()
+            XL = self.xaxis.get_major_locator().view_limits(x0, x1)
             self.set_xbound(XL)
         if scaley:
-            YL = self.yaxis.get_major_locator().autoscale()
+            YL = self.yaxis.get_major_locator().view_limits(y0, y1)
             self.set_ybound(YL)
 
     #### Drawing

Modified: trunk/matplotlib/lib/matplotlib/ticker.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/ticker.py   2008-10-23 19:56:04 UTC (rev 
6314)
+++ trunk/matplotlib/lib/matplotlib/ticker.py   2008-10-24 00:08:58 UTC (rev 
6315)
@@ -641,9 +641,17 @@
         'Return the locations of the ticks'
         raise NotImplementedError('Derived must override')
 
+    def view_limits(self, vmin, vmax):
+        """
+        select a scale for the range from vmin to vmax
+
+        Normally This will be overridden.
+        """
+        return mtransforms.nonsingular(vmin, vmax)
+
     def autoscale(self):
         'autoscale the view limits'
-        return mtransforms.nonsingular(*self.axis.get_view_interval())
+        return self.view_limits(*self.axis.get_view_interval())
 
     def pan(self, numsteps):
         'Pan numticks (can be positive or negative)'
@@ -773,11 +781,9 @@
     def _set_numticks(self):
         self.numticks = 11  # todo; be smart here; this is just for dev
 
-    def autoscale(self):
+    def view_limits(self, vmin, vmax):
         'Try to choose the view limits intelligently'
 
-        vmin, vmax = self.axis.get_data_interval()
-
         if vmax<vmin:
             vmin, vmax = vmax, vmin
 
@@ -859,13 +865,11 @@
         locs = vmin + np.arange(n+1) * base
         return locs
 
-    def autoscale(self):
+    def view_limits(self, dmin, dmax):
         """
         Set the view limits to the nearest multiples of base that
         contain the data
         """
-        dmin, dmax = self.axis.get_data_interval()
-
         vmin = self._base.le(dmin)
         vmax = self._base.ge(dmax)
         if vmin==vmax:
@@ -946,8 +950,7 @@
         vmin, vmax = mtransforms.nonsingular(vmin, vmax, expander = 0.05)
         return self.bin_boundaries(vmin, vmax)
 
-    def autoscale(self):
-        dmin, dmax = self.axis.get_data_interval()
+    def view_limits(self, dmin, dmax):
         if self._symmetric:
             maxabs = max(abs(dmin), abs(dmax))
             dmin = -maxabs
@@ -1043,9 +1046,9 @@
 
         return np.array(ticklocs)
 
-    def autoscale(self):
+    def view_limits(self, vmin, vmax):
         'Try to choose the view limits intelligently'
-        vmin, vmax = self.axis.get_data_interval()
+
         if vmax<vmin:
             vmin, vmax = vmax, vmin
 
@@ -1114,10 +1117,9 @@
             ticklocs = np.sign(decades) * b ** np.abs(decades)
         return np.array(ticklocs)
 
-    def autoscale(self):
+    def view_limits(self, vmin, vmax):
         'Try to choose the view limits intelligently'
         b = self._transform.base
-        vmin, vmax = self.axis.get_data_interval()
         if vmax<vmin:
             vmin, vmax = vmax, vmin
 
@@ -1167,13 +1169,12 @@
         d = abs(vmax-vmin)
         self._locator = self.get_locator(d)
 
-    def autoscale(self):
+    def view_limits(self, vmin, vmax):
         'Try to choose the view limits intelligently'
 
-        vmin, vmax = self.axis.get_data_interval()
         d = abs(vmax-vmin)
         self._locator = self.get_locator(d)
-        return self._locator.autoscale()
+        return self._locator.view_limits(vmin, vmax)
 
     def get_locator(self, d):
         'pick the best locator based on a distance'


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