In other words, the Figure is the blank canvas you ‘paint’ all your plots on. You can have multiple independent figures and Figures can contain multiple Subplots It is the overall window/page that everything is drawn on. Matplotlib Figure Sizeįirst off, what is the Figure? To quote the AnatomyOfMatplotlib: You can either change the size of the entire Figure or the size of the Subplots themselves. ![]() You have total control over the size of subplots in matplotlib. To change the height of a subplot in matplotlib, see the next section. plt.subplot(2, 2, 1)Īdd an overall title to a subplot in matplotlib with the plt.suptitle() function (it stands for ‘super title’). You can add a title to each subplot with the plt.title() function. Now, let’s look at how to add more info to our subplots in matplotib. It’s an easy way to make your plots look great.Ĭheck out the docs more information and arguments that tight_layout in matplotlib accepts. I use plt.tight_layout() in every single plot (without colobars or legends) and I recommend you do as well. Now there is less space between the plots but everything is still readable. It accepts a float in the range and is a fraction of the font size. You can adjust this with the pad keyword. Now there is plenty of space between the plots. Let’s see the most basic example without any labels or titles. Also, note that it does not work too well with legends or colorbars – you’ll see how to work with them later. It’s not perfect but often does a really good job.
0 Comments
Leave a Reply. |