8000 Backport PR #20662: Don't forget to disable autoscaling after interac… · matplotlib/matplotlib@10a2a40 · GitHub
[go: up one dir, main page]

Skip to content

Commit 10a2a40

Browse files
jklymakmeeseeksmachine
authored andcommitted
Backport PR #20662: Don't forget to disable autoscaling after interactive zoom.
1 parent d5de944 commit 10a2a40

File tree

2 files changed

+6
-11
lines changed

2 files changed

+6
-11
lines changed

lib/matplotlib/axes/_base.py

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4130,33 +4130,24 @@ def _set_view_from_bbox(self, bbox, direction='in',
41304130
Whether this axis is twinned in the *y*-direction.
41314131
"""
41324132
if len(bbox) == 3:
4133-
Xmin, Xmax = self.get_xlim()
4134-
Ymin, Ymax = self.get_ylim()
4135-
41364133
xp, yp, scl = bbox # Zooming code
4137-
41384134
if scl == 0: # Should not happen
41394135
scl = 1.
4140-
41414136
if scl > 1:
41424137
direction = 'in'
41434138
else:
41444139
direction = 'out'
41454140
scl = 1/scl
4146-
41474141
# get the limits of the axes
4148-
tranD2C = self.transData.transform
4149-
xmin, ymin = tranD2C((Xmin, Ymin))
4150-
xmax, ymax = tranD2C((Xmax, Ymax))
4151-
4142+
(xmin, ymin), (xmax, ymax) = self.transData.transform(
4143+
np.transpose([self.get_xlim(), self.get_ylim()]))
41524144
# set the range
41534145
xwidth = xmax - xmin
41544146
ywidth = ymax - ymin
41554147
xcen = (xmax + xmin)*.5
41564148
ycen = (ymax + ymin)*.5
41574149
xzc = (xp*(scl - 1) + xcen)/scl
41584150
yzc = (yp*(scl - 1) + ycen)/scl
4159-
41604151
bbox = [xzc - xwidth/2./scl, yzc - ywidth/2./scl,
41614152
xzc + xwidth/2./scl, yzc + ywidth/2./scl]
41624153
elif len(bbox) != 4:
@@ -4209,8 +4200,10 @@ def _set_view_from_bbox(self, bbox, direction='in',
42094200

42104201
if not twinx and mode != "y":
42114202
self.set_xbound(new_xbound)
4203+
self.set_autoscalex_on(False)
42124204
if not twiny and mode != "x":
42134205
self.set_ybound(new_ybound)
4206+
self.set_autoscaley_on(False)
42144207

42154208
def start_pan(self, x, y, button):
42164209
"""

lib/matplotlib/tests/test_backend_bases.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,8 @@ def test_interactive_zoom():
178178
tb.zoom()
179179
assert ax.get_navigate_mode() is None
180180

181+
assert not ax.get_autoscalex_on() and not ax.get_autoscaley_on()
182+
181183

182184
def test_toolbar_zoompan():
183185
expected_warning_regex = (

0 commit comments

Comments
 (0)
0