Skip to content

Commit f76bba4

Browse files
authored
Merge pull request #28491 from meeseeksmachine/auto-backport-of-pr-28487-on-v3.9.x
Backport PR #28487 on branch v3.9.x (Fix autoscaling with axhspan)
2 parents 8ccd2ee + 475d5b7 commit f76bba4

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

lib/matplotlib/axes/_axes.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1028,7 +1028,7 @@ def axhspan(self, ymin, ymax, xmin=0, xmax=1, **kwargs):
10281028
# For Rectangles and non-separable transforms, add_patch can be buggy
10291029
# and update the x limits even though it shouldn't do so for an
10301030
# yaxis_transformed patch, so undo that update.
1031-
ix = self.dataLim.intervalx
1031+
ix = self.dataLim.intervalx.copy()
10321032
mx = self.dataLim.minposx
10331033
self.add_patch(p)
10341034
self.dataLim.intervalx = ix

lib/matplotlib/tests/test_axes.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8195,10 +8195,10 @@ def test_relative_ticklabel_sizes(size):
81958195
def test_multiplot_autoscale():
81968196
fig = plt.figure()
81978197
ax1, ax2 = fig.subplots(2, 1, sharex='all')
8198-
ax1.scatter([1, 2, 3, 4], [2, 3, 2, 3])
8198+
ax1.plot([18000, 18250, 18500, 18750], [2, 3, 2, 3])
81998199
ax2.axhspan(-5, 5)
82008200
xlim = ax1.get_xlim()
8201-
assert np.allclose(xlim, [0.5, 4.5])
8201+
assert np.allclose(xlim, [18000, 18800])
82028202

82038203

82048204
def test_sharing_does_not_link_positions():

0 commit comments

Comments
 (0)
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