You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
tight_layout is incorrect for certain title sizes #8201
I am using Python 3.4.4 |Anaconda 2.3.0 (64-bit) on win64 bits, with latest matplotlib and pyqt updated by conda install xx
for the following code, if I use unicode title in the for-loop, the images are too small. However, if I use English title, the images' size are expected
changed the title [-]unicode title does not go well with gcf().tight_layout(), which yields bad image size[/-][+]tight_layout is incorrect for certain title sizes[/+]on Apr 22, 2020
This actually does have anything to do with unicode. It's just that for certain title lengths, tight_layout shrinks the axes bbox in a vain attempt of decreasing the title size as well, but of course that doesn't work; for even longer titles it just gives up and doesn't shrink the axes.
Minimalish repro:
frompylabimport*fig, axs=subplots(2, 3)
foraxinaxs.flat:
ax.imshow([[0]])
ax.set_title("so long tight_layout() just gives up", fontsize=20)
fig.tight_layout()
fig, axs=subplots(2, 3)
foraxinaxs.flat:
ax.imshow([[0]])
ax.set_title("just long enough to fail", fontsize=20)
fig.tight_layout()
show()
So, I guess its a valid question if tight_layout and constrained_layout should even care about the title or xlabel for the x-direction calculation, or the ylabel for y-direction calculation. Shrinking the axes doesn't make more room. That makes the code more complicated, but maybe not terribly so.
Activity
[-]unicode title does not go well with gcf().tight_layout(), which yields bad image size[/-][+]tight_layout is incorrect for certain title sizes[/+]anntzer commentedon Apr 22, 2020
This actually does have anything to do with unicode. It's just that for certain title lengths, tight_layout shrinks the axes bbox in a vain attempt of decreasing the title size as well, but of course that doesn't work; for even longer titles it just gives up and doesn't shrink the axes.
Minimalish repro:
jklymak commentedon Apr 22, 2020
So, I guess its a valid question if
tight_layoutandconstrained_layoutshould even care about the title or xlabel for the x-direction calculation, or the ylabel for y-direction calculation. Shrinking the axes doesn't make more room. That makes the code more complicated, but maybe not terribly so.anntzer commentedon Apr 22, 2020
Ah, very good point, I guess we could just exclude them from tightbbox computation (but only in the "irrelevant" direction).