Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 475d5b7

Browse filesBrowse files
QuLogicmeeseeksmachine
authored andcommitted
Backport PR #28487: Fix autoscaling with axhspan
1 parent 51decc5 commit 475d5b7
Copy full SHA for 475d5b7

File tree

2 files changed

+3
-3
lines changed
Filter options

2 files changed

+3
-3
lines changed

‎lib/matplotlib/axes/_axes.py

Copy file name to clipboardExpand all lines: lib/matplotlib/axes/_axes.py
+1-1Lines 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

Copy file name to clipboardExpand all lines: lib/matplotlib/tests/test_axes.py
+2-2Lines 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 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.