Bug summary
Code for reproduction
This code fails:
import matplotlib.pyplot as plt f, axarr = plt.subplots(2, 2) axarr[1][1].set_visible(False) plt.tight_layout()
This code succeeds:
import matplotlib.pyplot as plt f, axarr = plt.subplots(2, 2) axarr[1][1].axis('off') plt.tight_layout()
Actual outcome
AttributeError: 'NoneType' object has no attribute 'is_bbox'
Expected outcome
Looks like the tight_layout code is iterating over all of the subplots rather than just the visible ones
My suspicion is that adding a condition to the list comprehension:
tight_bbox_raw = union([ax.get_tightbbox(renderer) for ax in subplots])
at line 126 of matplotlib.tight_layout.py should do the trick.
Those two commands do very different things, axis('off') makes the spines invisible, but everything else is still visible ex
fig, ax = plt.subplots() ax.plot(range(5)) ax.axis('off')
gives
where are ax.set_visible(False) makes the Axes object (and all of it's children) are not included in the draw tree.
Which is why they look the same output-wise when the plot is empty in the first place (except for dimensional differences), gotcha.
Activity
WeatherGod commented on Mar 8, 2017
Looks like the tight_layout code is iterating over all of the subplots rather than just the visible ones
WeatherGod commented on Mar 8, 2017
My suspicion is that adding a condition to the list comprehension:
at line 126 of matplotlib.tight_layout.py should do the trick.
tacaswell commented on Mar 10, 2017
Those two commands do very different things, axis('off') makes the spines invisible, but everything else is still visible ex
gives

where are ax.set_visible(False) makes the Axes object (and all of it's children) are not included in the draw tree.
ResidentMario commented on Mar 10, 2017
Which is why they look the same output-wise when the plot is empty in the first place (except for dimensional differences), gotcha.