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
In one of the common use cases, a figure with a few subplots, it would be nice if a figure title could be taken into account; otherwise it will overlap the top subplots.
I can see from the code that the suptitle is just a simple Text; maybe the figure could keep track of the last Text object that got created using suptitle(), and so be able to take it into account when calculating the tight layout params.
The text was updated successfully, but these errors were encountered:
I'll just copy my answer (with slight modification) for the record.
I'm afraid that, unfortunately, it won't be fixed soon (if ever, as far as I can tell).
What "tight_layout" does is to adjust the subplot parameters of the
figure so that the "subplots" fit in. Artists whose position is set in the figure coordinate (e.g., texts created with figtext, suptitle, etc) therefore are not affected by the subplot parameters, i.e. there is not
much thing we can do for these artists within the current
implementation. It would be better if some warning is printed in such
case (there are lots of cases that tight_layout will fail), but this
is not currently done.
Depending on your need, you may leave out some area for figtext (or suptitle) when
you call "tight_layout". This is only supported for gridspec though.
importmatplotlib.pyplotaspltimportmatplotlib.gridspecasgridspecfig=plt.figure()
gs1=gridspec.GridSpec(2, 2)
ax_list= [fig.add_subplot(ss) forssings1]
fig.text (02, 0, "test", horizontalalignment='left',
verticalalignment='bottom', size=5)
fig.text (0.5, 1, "01", horizontalalignment='left',
verticalalignment='top', size='x-small')
gs1.tight_layout(fig, rect=[0, 0.03, 1, 0.97]) # adjust rect parameter while leaving some room for figtext.
I don't know the details of tight_layout, but thinking a little bigger, a full blown geometry manager would be the best possible solution here... MEP (matplotlib enhancement proposal) required.
The tight_layout function is very useful.
In one of the common use cases, a figure with a few subplots, it would be nice if a figure title could be taken into account; otherwise it will overlap the top subplots.
I can see from the code that the suptitle is just a simple Text; maybe the figure could keep track of the last Text object that got created using suptitle(), and so be able to take it into account when calculating the tight layout params.
The text was updated successfully, but these errors were encountered: