Skip to content

Commit

Permalink
Backport PR matplotlib#28487: Fix autoscaling with axhspan
Browse files Browse the repository at this point in the history
  • Loading branch information
QuLogic authored and meeseeksmachine committed Jun 29, 2024
1 parent 51decc5 commit 475d5b7
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib/matplotlib/axes/_axes.py
Original file line number Diff line number Diff line change
Expand Up @@ -1028,7 +1028,7 @@ def axhspan(self, ymin, ymax, xmin=0, xmax=1, **kwargs):
# For Rectangles and non-separable transforms, add_patch can be buggy
# and update the x limits even though it shouldn't do so for an
# yaxis_transformed patch, so undo that update.
ix = self.dataLim.intervalx
ix = self.dataLim.intervalx.copy()
mx = self.dataLim.minposx
self.add_patch(p)
self.dataLim.intervalx = ix
Expand Down
4 changes: 2 additions & 2 deletions lib/matplotlib/tests/test_axes.py
Original file line number Diff line number Diff line change
Expand Up @@ -8195,10 +8195,10 @@ def test_relative_ticklabel_sizes(size):
def test_multiplot_autoscale():
fig = plt.figure()
ax1, ax2 = fig.subplots(2, 1, sharex='all')
ax1.scatter([1, 2, 3, 4], [2, 3, 2, 3])
ax1.plot([18000, 18250, 18500, 18750], [2, 3, 2, 3])
ax2.axhspan(-5, 5)
xlim = ax1.get_xlim()
assert np.allclose(xlim, [0.5, 4.5])
assert np.allclose(xlim, [18000, 18800])


def test_sharing_does_not_link_positions():
Expand Down

0 comments on commit 475d5b7

Please sign in to comment.