Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 81e54b4

Browse files
committed
patched zoom to rect: instead of cancel, relasing oustide the axes means now that one uses axis limits instead of cursor position for the relevant limit
svn path=/trunk/matplotlib/; revision=737
1 parent b067c4a commit 81e54b4

1 file changed

Lines changed: 22 additions & 6 deletions

File tree

lib/matplotlib/backend_bases.py

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1069,7 +1069,7 @@ def release_zoom(self, event):
10691069

10701070
lastx, lasty, a, ind, lim, trans = self._xypress
10711071
# ignore singular clicks - 5 pixels is a threshold
1072-
if abs(x-lastx)<5 or abs(y-lasty)<5 or not a.in_axes(x,y):
1072+
if abs(x-lastx)<5 or abs(y-lasty)<5:
10731073
self._xypress = None
10741074
self.release(event)
10751075
self.draw()
@@ -1083,11 +1083,27 @@ def release_zoom(self, event):
10831083
Xmin,Xmax=a.get_xlim()
10841084
Ymin,Ymax=a.get_ylim()
10851085

1086-
if (x<lastx and Xmin<Xmax) or (x>lastx and Xmin>Xmax): xmin, xmax = x, lastx
1087-
else: xmin, xmax = lastx, x
1088-
1089-
if (y<lasty and Ymin<Ymax) or (y>lasty and Ymin>Ymax): ymin, ymax = y, lasty
1090-
else: ymin, ymax = lasty, y
1086+
if Xmin < Xmax:
1087+
if x<lastx: xmin, xmax = x, lastx
1088+
else: xmin, xmax = lastx, x
1089+
if xmin < Xmin: xmin=Xmin
1090+
if xmax > Xmax: xmax=Xmax
1091+
else:
1092+
if x>lastx: xmin, xmax = x, lastx
1093+
else: xmin, xmax = lastx, x
1094+
if xmin > Xmin: xmin=Xmin
1095+
if xmax < Xmax: xmax=Xmax
1096+
1097+
if Ymin < Ymax:
1098+
if y<lasty: ymin, ymax = y, lasty
1099+
else: ymin, ymax = lasty, y
1100+
if ymin < Ymin: ymin=Ymin
1101+
if ymax > Ymax: ymax=Ymax
1102+
else:
1103+
if y>lasty: ymin, ymax = y, lasty
1104+
else: ymin, ymax = lasty, y
1105+
if ymin > Ymin: ymin=Ymin
1106+
if ymax < Ymax: ymax=Ymax
10911107

10921108
if self._button_pressed == 1:
10931109
a.set_xlim((xmin, xmax))

0 commit comments

Comments
 (0)