Matplotlib constrained_layout vs. tight_layout
In general, Matplotlib figures look better with constrained_layout. The older tight_layout is not as flexible and can lead to overlapping text, particularly with “suptitle”.
To make figures with subplots and suptitle work better, use:
matplotlib.pyplot.figure(layout='constrained')
# or
matplotlib.figure.Figure(constrained_layout=True)
Example:
import matplotlib.pyplot as plt
fg = plt.figure(layout='constrained')
ax = fg.subplots(3, 1)
for i in range(3):
ax[i].plot(range(5+5*i))
fg.suptitle('lots of lines')
plt.show()