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

Skip to content

Backport PR #28487 on branch v3.9.x (Fix autoscaling with axhspan) #28491

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading