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 f5067c1

Browse filesBrowse files
authored
Fix autoscaling with axhspan (#28487)
This only triggers when the normal (without an `axhspan` call) autolimits are far from 0, so modify a test to match that.
1 parent 00cbd9c commit f5067c1
Copy full SHA for f5067c1

File tree

Expand file treeCollapse file tree

2 files changed

+3
-3
lines changed
Filter options
Expand file treeCollapse file tree

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
@@ -8250,10 +8250,10 @@ def test_relative_ticklabel_sizes(size):
82508250
def test_multiplot_autoscale():
82518251
fig = plt.figure()
82528252
ax1, ax2 = fig.subplots(2, 1, sharex='all')
8253-
ax1.scatter([1, 2, 3, 4], [2, 3, 2, 3])
8253+
ax1.plot([18000, 18250, 18500, 18750], [2, 3, 2, 3])
82548254
ax2.axhspan(-5, 5)
82558255
xlim = ax1.get_xlim()
8256-
assert np.allclose(xlim, [0.5, 4.5])
8256+
assert np.allclose(xlim, [18000, 18800])
82578257

82588258

82598259
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.