Skip to content

[WIP] Close #6968 make autoscale respect tight #7024

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

Closed
wants to merge 2 commits into from
Closed
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/_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -2198,7 +2198,7 @@ def autoscale_view(self, tight=None, scalex=True, scaley=True):
else:
_tight = self._tight = bool(tight)

if self._xmargin or self._ymargin:
if (self._xmargin or self._ymargin) and not _tight:
margins = {
'top': True,
'bottom': True,
Expand Down
10 changes: 10 additions & 0 deletions lib/matplotlib/tests/test_axes.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,16 @@ def test_autoscale_tiny_range():
ax[i].plot([0, 1], [1, 1 + y1])


@cleanup
def test_autoscale_tight():
fig, ax = plt.subplots(1, 1)
ax.plot([1, 2, 3, 4])
ax.autoscale(enable=True, axis='x', tight=False)
ax.autoscale(enable=True, axis='y', tight=True)
assert_allclose(ax.get_xlim(), (-0.15, 3.15))
assert_allclose(ax.get_ylim(), (1.0, 4.0))


@image_comparison(baseline_images=['offset_points'],
remove_text=True)
def test_basic_annotate():
Expand Down