From 10a2a408258b7e79e9f0d40c147f8bcc001d0a28 Mon Sep 17 00:00:00 2001 From: Jody Klymak Date: Tue, 20 Jul 2021 08:49:55 -0700 Subject: [PATCH] Backport PR #20662: Don't forget to disable autoscaling after interactive zoom. --- lib/matplotlib/axes/_base.py | 15 ++++----------- lib/matplotlib/tests/test_backend_bases.py | 2 ++ 2 files changed, 6 insertions(+), 11 deletions(-) diff --git a/lib/matplotlib/axes/_base.py b/lib/matplotlib/axes/_base.py index 2a97499e0674..0ded09888d56 100644 --- a/lib/matplotlib/axes/_base.py +++ b/lib/matplotlib/axes/_base.py @@ -4130,25 +4130,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 @@ -4156,7 +4148,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: @@ -4209,8 +4200,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 = ( pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy