Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit e8e12df

Browse files
authored
MNT: Warn if fixed aspect overwrites explicitly set data limits (#28683)
Closes #28673.
1 parent ba05b44 commit e8e12df

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

lib/matplotlib/axes/_base.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1713,7 +1713,8 @@ def set_adjustable(self, adjustable, share=False):
17131713
----------
17141714
adjustable : {'box', 'datalim'}
17151715
If 'box', change the physical dimensions of the Axes.
1716-
If 'datalim', change the ``x`` or ``y`` data limits.
1716+
If 'datalim', change the ``x`` or ``y`` data limits. This
1717+
may ignore explicitly defined axis limits.
17171718
17181719
share : bool, default: False
17191720
If ``True``, apply the settings to all shared Axes.
@@ -2030,11 +2031,17 @@ def apply_aspect(self, position=None):
20302031
yc = 0.5 * (ymin + ymax)
20312032
y0 = yc - Ysize / 2.0
20322033
y1 = yc + Ysize / 2.0
2034+
if not self.get_autoscaley_on():
2035+
_log.warning("Ignoring fixed y limits to fulfill fixed data aspect "
2036+
"with adjustable data limits.")
20332037
self.set_ybound(y_trf.inverted().transform([y0, y1]))
20342038
else:
20352039
xc = 0.5 * (xmin + xmax)
20362040
x0 = xc - Xsize / 2.0
20372041
x1 = xc + Xsize / 2.0
2042+
if not self.get_autoscalex_on():
2043+
_log.warning("Ignoring fixed x limits to fulfill fixed data aspect "
2044+
"with adjustable data limits.")
20382045
self.set_xbound(x_trf.inverted().transform([x0, x1]))
20392046

20402047
def axis(self, arg=None, /, *, emit=True, **kwargs):

0 commit comments

Comments
 (0)