I'm using Spider + Qt as Graphics backend.
In the script I do some subplots and finally call tight_layout()
, but it does not work:
fig, axs = plt.subplots(..)
axs[..].plot()
...
fig.tight_layout()
Then I call the fig.tight_layout()
again from the IPython console (I use the fig instance of the above plotted figure), and (o, miracle!) it works out!
What is wrong? I suspect, that Qt processes plotting requests with some delay (at least, the graph window appears after the all script is finished), but don't understand how to fix that, except manually call fig.tight_layout()
afterwards
So, the main problem, that fig.tight_layout()
works, but only when the figure is already displayed on the screen. It does not work for new figures, but if I run the script for the second time and use the same figure name (so, the same figure window) - it works correctly. Or if I call it from IPython console.
P.S. The solution, suggested by Trenton McKinney (fig, axs = plt.subplots(tight_layout=True)
) works, so the question may be marked as Solved