August 2017
Beginner to intermediate
334 pages
8h 22m
English
When we have a group of subplots, depending on various layout concerns (including how much information we are showing on each axis), we may want to adjust the gap sizes between different subplots. In general, we would often like to align subplots with minimum white space. Matplotlib provides a function, pyplot.tight_layout(), for this purpose.
If we replace the plt.show() in the previous example of 2 x 2 subplots with plt.tight_layout(), the gap between columns will narrow. This can be further customized by parsing the parameters pad, w_pad, h_pad into tight_layout(), which corresponds to the padding between the figure edge and edges of subplots, and the height and the width between adjacent subplots. ...
Read now
Unlock full access