Use Matplotlib constrained_layout instead of tight_layout

Many legacy tutorials and examples for Matplotlib use tight_layout(). A key problem with tight_layout() and subplots is that tight_layout destroys suptitle(). Matplotlib constrained_layout is still being improved and is recommended over tight_layout().

To make figures with subplots and suptitle work better, use figure(constrained_layout=True):

from matplotlib.pyplot import figure, show

fg = figure(constrained_layout=True)
ax = fg.subplots(3, 1)

for i in range(3):

fg.suptitle('lots of lines')


This plot is much superior to fg.tight_layout()