From d6a9434bce8cbf0b5a90fb15139e6c6845c0112d Mon Sep 17 00:00:00 2001 From: Tim Hoffmann <2836374+timhoffm@users.noreply.github.com> Date: Thu, 8 Aug 2024 15:22:56 +0200 Subject: [PATCH] MNT: Warn if fixed aspect overwrites explicitly set data limits Closes #28673. --- lib/matplotlib/axes/_base.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/matplotlib/axes/_base.py b/lib/matplotlib/axes/_base.py index a0e588569465..649b6f55e9a7 100644 --- a/lib/matplotlib/axes/_base.py +++ b/lib/matplotlib/axes/_base.py @@ -1705,7 +1705,8 @@ def set_adjustable(self, adjustable, share=False): ---------- adjustable : {'box', 'datalim'} If 'box', change the physical dimensions of the Axes. - If 'datalim', change the ``x`` or ``y`` data limits. + If 'datalim', change the ``x`` or ``y`` data limits. This + may ignore explicitly defined axis limits. share : bool, default: False If ``True``, apply the settings to all shared Axes. @@ -2022,11 +2023,17 @@ def apply_aspect(self, position=None): yc = 0.5 * (ymin + ymax) y0 = yc - Ysize / 2.0 y1 = yc + Ysize / 2.0 + if not self.get_autoscaley_on(): + _log.warning("Ignoring fixed y limits to fulfill fixed data aspect " + "with adjustable data limits.") self.set_ybound(y_trf.inverted().transform([y0, y1])) else: xc = 0.5 * (xmin + xmax) x0 = xc - Xsize / 2.0 x1 = xc + Xsize / 2.0 + if not self.get_autoscalex_on(): + _log.warning("Ignoring fixed x limits to fulfill fixed data aspect " + "with adjustable data limits.") self.set_xbound(x_trf.inverted().transform([x0, x1])) def axis(self, arg=None, /, *, emit=True, **kwargs):
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: