Multiple Plots in 1 Figure
-
We can make multiple graphics in one figure. This goes very well for comparing charts or for sharing data from several types of charts easily with a single image.
-
The .subplot() method is used to add multiple plots in one figure. It takes three arguments:
- nrows: number of rows in the figure
- ncols: number of columns in the figure
- index: index of the plot
-
Let's see how variables are plotted with different row and column configurations in the figures.
-
The function subplot creates a figure and a set of subplots. It is a wrapper function to make it convenient to create common layouts of subplots, including the enclosing figure object, in a single call.
-
You can even give a Title to your subplots using the suptitle method! No, the 'p' is not a typing mistake.
-
The subplot function returns a figure and an Axes object or an array of Axes objects.
Changing Plot Size
If we call the subplot function without any parameters - like we do in the following example - a Figure object and one Axes object will be returned:

1 row and 2 columns - Method 1

1 row and 2 columns - Method 2

Overlapping Values
-
Aren't those overlapping axis values annoying? Matplotlib has a solution for that too.
-
Simply put sharey=True inside the subplot function. The two subplots will now share the y axis values.
-
Try it out!
2 rows and 1 column

2 rows and 2 columns
Think of this as a 2
