FIX: don't pad axes for ticks if they aren't visible or axis off #11210
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
PR Summary
Since 1.5.3 (two years ago) we added:
matplotlib/lib/matplotlib/axes/_base.py
Lines 580 to 589 in 1652ed1
First, this seems like a funny place to put the padding for ticks - I'd have expected it to be in the axis bbox, not the axes bbox. But presumably someone wanted to know the extent of the axes and its ticks w/o knowing the rest of the decorators? The original issues that spurred #5683 seemed to be tight_layout not respecting outward ticks. IMHO this "fix" was wrong and the axis bboxes should include the ticks not the
axes
, Butxaxis.get_tightbbox
does not include the ticks even though it controls everything about the ticks.Second,
ax.set_axis_off
sets aax.axison=False
, but it doesn't change the visibility of the axis, which is still True. I haven't fixed this, but it seems strange to have two flags that control the visibility of an axis.Anyways, this is an easy fix given how things are now to make the tightbbox actually behave like there are no ticks present.
Closes: #11203
before
after
PR Checklist