-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
tight_layout ignores invisible axes #2008
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
tight_layout ignores invisible axes #2008
Conversation
👍, but maybe add a test? |
+1 from me, too, with a test. |
@leejjoon - this is good to go once we have a test. Any chance you would be able to do that, and then we can go ahead and merge. Thanks, |
Should we go for this with out a test? |
And it will also need to be re-worked for the |
This does not work as expected. Here is a minimal test import matplotlib.pyplot as plt
x = y = [0, 1]
fig, axs = plt.subplots(2, 2)
axs = axs.flat
for ax in axs:
ax.plot(x, y)
axs[1].set_visible(False)
axs[3].set_visible(False)
fig.patch.set_color('cyan')
plt.tight_layout()
plt.show() Without this PR Traceback (most recent call last):
File "temp5.py", line 14, in <module>
plt.tight_layout()
File "/home/hassan/scm/python/matplotlib/lib/matplotlib/pyplot.py", line 1366, in tight_layout
fig.tight_layout(pad=pad, h_pad=h_pad, w_pad=w_pad, rect=rect)
File "/home/hassan/scm/python/matplotlib/lib/matplotlib/figure.py", line 1717, in tight_layout
rect=rect)
File "/home/hassan/scm/python/matplotlib/lib/matplotlib/tight_layout.py", line 349, in get_tight_layout_figure
pad=pad, h_pad=h_pad, w_pad=w_pad)
File "/home/hassan/scm/python/matplotlib/lib/matplotlib/tight_layout.py", line 128, in auto_adjust_subplotpars
fig.transFigure.inverted())
File "/home/hassan/scm/python/matplotlib/lib/matplotlib/transforms.py", line 1069, in __init__
if not bbox.is_bbox:
AttributeError: 'NoneType' object has no attribute 'is_bbox' With this PR |
I disagree w/ the PR, and given its languishing state suggest it be closed. If the user makes room for 12 axes and only uses 2, I'd assume they had a plan for the other 10 slots. In #9082, I went to pretty great lengths to make sure that empty slots were maintained for the user. |
Closing, given that this doesn't work as advertised, has languished, and I disagree w/ its goal. Feel free to reopen if you disagree! |
tight_layout
currently tries to make room for every subplot(-like axes) regardless of their visibility. With this PR, only visible axes are accounted.