diff --git a/lib/matplotlib/axes/_base.py b/lib/matplotlib/axes/_base.py index 10ab40b14737..802fd3c9971c 100644 --- a/lib/matplotlib/axes/_base.py +++ b/lib/matplotlib/axes/_base.py @@ -4292,25 +4292,17 @@ def _set_view_from_bbox(self, bbox, direction='in', Whether this axis is twinned in the *y*-direction. """ if len(bbox) == 3: - Xmin, Xmax = self.get_xlim() - Ymin, Ymax = self.get_ylim() - xp, yp, scl = bbox # Zooming code - if scl == 0: # Should not happen scl = 1. - if scl > 1: direction = 'in' else: direction = 'out' scl = 1/scl - # get the limits of the axes - tranD2C = self.transData.transform - xmin, ymin = tranD2C((Xmin, Ymin)) - xmax, ymax = tranD2C((Xmax, Ymax)) - + (xmin, ymin), (xmax, ymax) = self.transData.transform( + np.transpose([self.get_xlim(), self.get_ylim()])) # set the range xwidth = xmax - xmin ywidth = ymax - ymin @@ -4318,7 +4310,6 @@ def _set_view_from_bbox(self, bbox, direction='in', ycen = (ymax + ymin)*.5 xzc = (xp*(scl - 1) + xcen)/scl yzc = (yp*(scl - 1) + ycen)/scl - bbox = [xzc - xwidth/2./scl, yzc - ywidth/2./scl, xzc + xwidth/2./scl, yzc + ywidth/2./scl] elif len(bbox) != 4: @@ -4371,8 +4362,10 @@ def _set_view_from_bbox(self, bbox, direction='in', if not twinx and mode != "y": self.set_xbound(new_xbound) + self.set_autoscalex_on(False) if not twiny and mode != "x": self.set_ybound(new_ybound) + self.set_autoscaley_on(False) def start_pan(self, x, y, button): """ diff --git a/lib/matplotlib/tests/test_backend_bases.py b/lib/matplotlib/tests/test_backend_bases.py index 610897da173e..1550d3256c04 100644 --- a/lib/matplotlib/tests/test_backend_bases.py +++ b/lib/matplotlib/tests/test_backend_bases.py @@ -178,6 +178,8 @@ def test_interactive_zoom(): tb.zoom() assert ax.get_navigate_mode() is None + assert not ax.get_autoscalex_on() and not ax.get_autoscaley_on() + def test_toolbar_zoompan(): expected_warning_regex = (