Revision: 5053
          http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5053&view=rev
Author:   mmetz_bn
Date:     2008-04-20 03:45:32 -0700 (Sun, 20 Apr 2008)

Log Message:
-----------
Fixed double-zoom bug

Modified Paths:
--------------
    trunk/matplotlib/CHANGELOG
    trunk/matplotlib/lib/matplotlib/backend_bases.py

Modified: trunk/matplotlib/CHANGELOG
===================================================================
--- trunk/matplotlib/CHANGELOG  2008-04-20 01:33:46 UTC (rev 5052)
+++ trunk/matplotlib/CHANGELOG  2008-04-20 10:45:32 UTC (rev 5053)
@@ -1,3 +1,5 @@
+2008-04-20 Fix double-zoom bug. - MM
+
 2008-04-15 Speed up color mapping. - EF
 
 2008-04-12 Speed up zooming and panning of dense images. - EF

Modified: trunk/matplotlib/lib/matplotlib/backend_bases.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/backend_bases.py    2008-04-20 01:33:46 UTC 
(rev 5052)
+++ trunk/matplotlib/lib/matplotlib/backend_bases.py    2008-04-20 10:45:32 UTC 
(rev 5053)
@@ -1508,6 +1508,8 @@
         'the release mouse button callback in zoom to rect mode'
         if not self._xypress: return
 
+        last_a = []
+        
         for cur_xypress in self._xypress:
             x, y = event.x, event.y
             lastx, lasty, a, ind, lim, trans = cur_xypress
@@ -1526,28 +1528,42 @@
             x, y = inverse.transform_point( (x, y) )
             Xmin,Xmax=a.get_xlim()
             Ymin,Ymax=a.get_ylim()
+            
+            # detect twinx,y axes and avoid double zooming
+            twinx, twiny = False, False
+            if last_a:
+                for la in last_a:
+                    if a._shared_x_axes.joined(a,la): twinx=True
+                    if a._shared_y_axes.joined(a,la): twiny=True
+            last_a.append(a)
 
-            if Xmin < Xmax:
-                if x<lastx:  x0, x1 = x, lastx
-                else: x0, x1 = lastx, x
-                if x0 < Xmin: x0=Xmin
-                if x1 > Xmax: x1=Xmax
+            if twinx:
+                x0, x1 = Xmin, Xmax
             else:
-                if x>lastx:  x0, x1 = x, lastx
-                else: x0, x1 = lastx, x
-                if x0 > Xmin: x0=Xmin
-                if x1 < Xmax: x1=Xmax
+                if Xmin < Xmax:
+                    if x<lastx:  x0, x1 = x, lastx
+                    else: x0, x1 = lastx, x
+                    if x0 < Xmin: x0=Xmin
+                    if x1 > Xmax: x1=Xmax
+                else:
+                    if x>lastx:  x0, x1 = x, lastx
+                    else: x0, x1 = lastx, x
+                    if x0 > Xmin: x0=Xmin
+                    if x1 < Xmax: x1=Xmax
 
-            if Ymin < Ymax:
-                if y<lasty:  y0, y1 = y, lasty
-                else: y0, y1 = lasty, y
-                if y0 < Ymin: y0=Ymin
-                if y1 > Ymax: y1=Ymax
+            if twiny:
+                y0, y1 = Ymin, Ymax
             else:
-                if y>lasty:  y0, y1 = y, lasty
-                else: y0, y1 = lasty, y
-                if y0 > Ymin: y0=Ymin
-                if y1 < Ymax: y1=Ymax
+                if Ymin < Ymax:
+                    if y<lasty:  y0, y1 = y, lasty
+                    else: y0, y1 = lasty, y
+                    if y0 < Ymin: y0=Ymin
+                    if y1 > Ymax: y1=Ymax
+                else:
+                    if y>lasty:  y0, y1 = y, lasty
+                    else: y0, y1 = lasty, y
+                    if y0 > Ymin: y0=Ymin
+                    if y1 < Ymax: y1=Ymax
 
             if self._button_pressed == 1:
                 a.set_xlim((x0, x1))


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 2008 JavaOne(SM) Conference 
Don't miss this year's exciting event. There's still time to save $100. 
Use priority code J8TL2D2. 
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
_______________________________________________
Matplotlib-checkins mailing list
Matplotlib-checkins@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-checkins

Reply via email to