Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 5b87c98

Browse filesBrowse files
authored
Merge pull request #20662 from anntzer/svfb
Don't forget to disable autoscaling after interactive zoom.
2 parents 0dfa99d + 2f952f3 commit 5b87c98
Copy full SHA for 5b87c98

File tree

Expand file treeCollapse file tree

2 files changed

+6
-11
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+6
-11
lines changed

‎lib/matplotlib/axes/_base.py

Copy file name to clipboardExpand all lines: lib/matplotlib/axes/_base.py
+4-11Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4292,33 +4292,24 @@ def _set_view_from_bbox(self, bbox, direction='in',
42924292
Whether this axis is twinned in the *y*-direction.
42934293
"""
42944294
if len(bbox) == 3:
4295-
Xmin, Xmax = self.get_xlim()
4296-
Ymin, Ymax = self.get_ylim()
4297-
42984295
xp, yp, scl = bbox # Zooming code
4299-
43004296
if scl == 0: # Should not happen
43014297
scl = 1.
4302-
43034298
if scl > 1:
43044299
direction = 'in'
43054300
else:
43064301
direction = 'out'
43074302
scl = 1/scl
4308-
43094303
# get the limits of the axes
4310-
tranD2C = self.transData.transform
4311-
xmin, ymin = tranD2C((Xmin, Ymin))
4312-
xmax, ymax = tranD2C((Xmax, Ymax))
4313-
4304+
(xmin, ymin), (xmax, ymax) = self.transData.transform(
4305+
np.transpose([self.get_xlim(), self.get_ylim()]))
43144306
# set the range
43154307
xwidth = xmax - xmin
43164308
ywidth = ymax - ymin
43174309
xcen = (xmax + xmin)*.5
43184310
ycen = (ymax + ymin)*.5
43194311
xzc = (xp*(scl - 1) + xcen)/scl
43204312
yzc = (yp*(scl - 1) + ycen)/scl
4321-
43224313
bbox = [xzc - xwidth/2./scl, yzc - ywidth/2./scl,
43234314
xzc + xwidth/2./scl, yzc + ywidth/2./scl]
43244315
elif len(bbox) != 4:
@@ -4371,8 +4362,10 @@ def _set_view_from_bbox(self, bbox, direction='in',
43714362

43724363
if not twinx and mode != "y":
43734364
self.set_xbound(new_xbound)
4365+
self.set_autoscalex_on(False)
43744366
if not twiny and mode != "x":
43754367
self.set_ybound(new_ybound)
4368+
self.set_autoscaley_on(False)
43764369

43774370
def start_pan(self, x, y, button):
43784371
"""

‎lib/matplotlib/tests/test_backend_bases.py

Copy file name to clipboardExpand all lines: lib/matplotlib/tests/test_backend_bases.py
+2Lines 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)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.