Drawing Subplots
In designing layouts of visual aids, it is often necessary to organize multiple relevant plots into panels in the same figure, such as when illustrating different aspects of the same dataset. Matplotlib provides a few ways to create figures with multiple subplots.
Initiating a figure with plt.figure()
The plt.figure()
API is the API that is used to initiate a figure that serves as the base canvas. It takes in arguments that determines the number of figures and parameters such as size and background color of the plot image. It displays a new area as the canvas for plotting axes
when called. We wouldn't obtain any graphical output unless we add other plotting elements. If we were to call plt.show()
at this point, we would see a Matplotlib figure
object being returned, as shown in the following screen capture:
When we are plotting simple figures that involve only a single plot, without the need for multiple panels, we can omit calling plt.figure()
. If plt.figure()
is not called...