From 1ea7cceb8963db7b97b55ccd7cded0b76362654f Mon Sep 17 00:00:00 2001 From: Antony Lee Date: Sun, 18 Jul 2021 15:23:05 +0200 Subject: [PATCH 1/2] PEP8ify _set_view_from_bbox. --- lib/matplotlib/axes/_base.py | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/lib/matplotlib/axes/_base.py b/lib/matplotlib/axes/_base.py index 10ab40b14737..b5228622fa54 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: From 2f952f35a58f1cb887a670b404d38c2b6cde3ed3 Mon Sep 17 00:00:00 2001 From: Antony Lee Date: Sun, 18 Jul 2021 15:25:00 +0200 Subject: [PATCH 2/2] Don't forget to disable autoscaling after interactive zoom. (set_x/ybound doesn't disable autoscaling, unlike set_x/ylim.) --- lib/matplotlib/axes/_base.py | 2 ++ lib/matplotlib/tests/test_backend_bases.py | 2 ++ 2 files changed, 4 insertions(+) diff --git a/lib/matplotlib/axes/_base.py b/lib/matplotlib/axes/_base.py index b5228622fa54..802fd3c9971c 100644 --- a/lib/matplotlib/axes/_base.py +++ b/lib/matplotlib/axes/_base.py @@ -4362,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 = ( 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