FIX constrained_layout w/ hidden axes#14919
Conversation
|
Could easily be back ported if not a bother. |
56ecc84 to
eb410f0
Compare
|
Forget the above. Yes, this is the correct fix. If you want to not have the axes take part in the layout you should use |
|
An empty gridspec box gets a placeholder like this anyhow, so this is the smallest box that is possible for this spot if gridspec or I do this because if someone has a gap in their layout presumably they want it to be there. And it is needed to keep the axes in rows above or below a blank (for instance) aligned. This is somewhat poorly documented at: https://matplotlib.org/3.1.1/tutorials/intermediate/constrainedlayout_guide.html#empty-gridspec-slots |
|
Yes, I realized that 5 minutes after I posted (see edit above), sorry for the confusion. |
|
Too fast! Though I'll point out that even remove will still put a blank gridspec in there (actually an axes with all the elements made invisible!) |
| pos = ax.get_position(original=True) | ||
| tightbbox = ax.get_tightbbox(renderer=renderer) | ||
| bbox = invTransFig(tightbbox) | ||
| if tightbbox is None: |
There was a problem hiding this comment.
Just:
bbox = pos if tightbbox is None else invTransFig(tightbbox)
There was a problem hiding this comment.
I find those really hard to read a lot of the time.
There was a problem hiding this comment.
Actually, when reading a function for a basic understanding what it does I find this more easy.
It's just one line saying: "Sets bbox depending on some condition". The if/else is already more low level.
But not fighting over this.
dstansby
left a comment
There was a problem hiding this comment.
👍 with a comment on the test
eb410f0 to
1911cc8
Compare
18538e2 to
47f0128
Compare
|
flake8:
|
Update lib/matplotlib/tests/test_constrainedlayout.py Co-Authored-By: David Stansby <dstansby@gmail.com> FLAKE8
dc6186f to
c8ec3c6
Compare
|
Hmmm, I kept trying to rebase that change in, but I suspect I added the space in the "TST" commit, so it kept overwriting it. Ooops.... |
…919-on-v3.1.x Backport PR #14919 on branch v3.1.x (FIX constrained_layout w/ hidden axes)
PR Summary
If an axes is hidden (set_visible(False)) then it has no tightbbox. But we still need to position it w/
constrained_layout, pointed out in #14917 (thanks @ImportanceOfBeingErnest )Closes #14918
PR Checklist