diff --git a/lib/matplotlib/axes/_base.py b/lib/matplotlib/axes/_base.py index 0feb87e757d1..202b558947f5 100644 --- a/lib/matplotlib/axes/_base.py +++ b/lib/matplotlib/axes/_base.py @@ -2198,7 +2198,7 @@ def autoscale_view(self, tight=None, scalex=True, scaley=True): else: _tight = self._tight = bool(tight) - if self._xmargin or self._ymargin: + if (self._xmargin or self._ymargin) and not _tight: margins = { 'top': True, 'bottom': True, diff --git a/lib/matplotlib/tests/test_axes.py b/lib/matplotlib/tests/test_axes.py index 3d41e3c27422..c9600dc5a6db 100644 --- a/lib/matplotlib/tests/test_axes.py +++ b/lib/matplotlib/tests/test_axes.py @@ -166,6 +166,16 @@ def test_autoscale_tiny_range(): ax[i].plot([0, 1], [1, 1 + y1]) +@cleanup +def test_autoscale_tight(): + fig, ax = plt.subplots(1, 1) + ax.plot([1, 2, 3, 4]) + ax.autoscale(enable=True, axis='x', tight=False) + ax.autoscale(enable=True, axis='y', tight=True) + assert_allclose(ax.get_xlim(), (-0.15, 3.15)) + assert_allclose(ax.get_ylim(), (1.0, 4.0)) + + @image_comparison(baseline_images=['offset_points'], remove_text=True) def test_basic_annotate(): 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