If you’re working with data, you’ll often need to compare different datasets side by side or overlay multiple graphs to spot trends. Matplotlib offers several ways to do this, but understanding which method to use and how to implement it efficiently can save you time and make your visualizations clearer.
In this article, I’ll walk you through the most common methods to create multiple plots using Matplotlib.
Let’s get in!
Methods to Create Multiple Plots in Matplotlib
Now, I will explain to you the methods to create multiple plots in Matplotlib.
Read Matplotlib subplots_adjust
1: Use plt.subplot() for Multiple Plots in One Figure
One of the simplest ways to create multiple plots is to use the plt.subplot() function in Python. It allows you to divide your figure into a grid of rows and columns and place a plot in each grid cell.
Here’s how I usually approach it:
import matplotlib.pyplot as plt
import numpy as np
# Sample data: Quarterly sales for two U.S. regions
quarters = ['Q1', 'Q2', 'Q3', 'Q4']
sales_northeast = [25000, 27000, 30000, 32000]
sales_southwest = [22000, 26000, 28000, 31000]
plt.figure(figsize=(10, 5))
# First subplot: Northeast sales
plt.subplot(1, 2, 1) # 1 row, 2 columns, plot 1
plt.plot(quarters, sales_northeast, marker='o', color='blue')
plt.title('Northeast Region Sales')
plt.xlabel('Quarter')
plt.ylabel('Sales ($)')
# Second subplot: Southwest sales
plt.subplot(1, 2, 2) # 1 row, 2 columns, plot 2
plt.plot(quarters, sales_southwest, marker='o', color='green')
plt.title('Southwest Region Sales')
plt.xlabel('Quarter')
plt.ylabel('Sales ($)')
plt.tight_layout()
plt.show()I executed the above example code and added the screenshot below.

It’s easy and perfect for quick comparisons. I use it when I want to create multiple plots arranged in a grid without much hassle.
Check out Matplotlib log log plot
2: Use plt.subplots() for More Control
While plt.subplot() is handy, plt.subplots() offers more flexibility, especially when working with multiple axes objects.
Here’s an example where I visualize unemployment rates across two U.S. states over six months:
fig, axs = plt.subplots(2, 1, figsize=(8, 6)) # 2 rows, 1 column
months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun']
unemployment_texas = [5.1, 5.0, 4.8, 4.7, 4.5, 4.3]
unemployment_california = [7.2, 7.0, 6.8, 6.5, 6.3, 6.0]
# Texas unemployment plot
axs[0].plot(months, unemployment_texas, color='red', marker='x')
axs[0].set_title('Texas Unemployment Rate')
axs[0].set_ylabel('Unemployment (%)')
# California unemployment plot
axs[1].plot(months, unemployment_california, color='purple', marker='x')
axs[1].set_title('California Unemployment Rate')
axs[1].set_ylabel('Unemployment (%)')
axs[1].set_xlabel('Month')
plt.tight_layout()
plt.show()I executed the above example code and added the screenshot below.

It returns a figure and an array of axes, making it easier to customize each subplot individually. This method scales well when you have more plots or need precise control over layout and styling
Read Matplotlib plot_date
3: Plot Multiple Lines on the Same Axes
Sometimes, instead of separate plots, you want to overlay multiple lines on the same graph. This is useful when comparing trends directly.
For example, comparing average temperatures for New York and Chicago over a year:
months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun']
temp_ny = [30, 32, 45, 55, 65, 75]
temp_chicago = [25, 28, 40, 50, 60, 70]
plt.figure(figsize=(8, 4))
plt.plot(months, temp_ny, label='New York', marker='o')
plt.plot(months, temp_chicago, label='Chicago', marker='s')
plt.title('Average Monthly Temperatures')
plt.xlabel('Month')
plt.ylabel('Temperature (°F)')
plt.legend()
plt.grid(True)
plt.show()I executed the above example code and added the screenshot below.

Overlaying multiple lines allows for immediate visual comparison. It’s great for spotting differences or similarities in trends, like weather patterns or stock prices.
Check out Matplotlib Scatter Marker
4: Use GridSpec for Complex Layouts
When your visualization needs are more advanced, GridSpec from Matplotlib lets you create complex, customized layouts.
Here’s a quick example where I create a larger plot on the left and two smaller plots stacked on the right, simulating a dashboard layout:
import matplotlib.gridspec as gridspec
fig = plt.figure(figsize=(10, 6))
gs = gridspec.GridSpec(2, 2, width_ratios=[3, 1])
# Large plot on the left
ax0 = plt.subplot(gs[:, 0])
ax0.plot(quarters, sales_northeast, label='Northeast')
ax0.plot(quarters, sales_southwest, label='Southwest')
ax0.set_title('Regional Sales Comparison')
ax0.set_ylabel('Sales ($)')
ax0.legend()
# Top right plot
ax1 = plt.subplot(gs[0, 1])
ax1.bar(quarters, sales_northeast, color='blue')
ax1.set_title('Northeast Sales')
# Bottom right plot
ax2 = plt.subplot(gs[1, 1])
ax2.bar(quarters, sales_southwest, color='green')
ax2.set_title('Southwest Sales')
plt.tight_layout()
plt.show()It’s perfect when your dashboard or report needs a custom layout that doesn’t fit a simple grid. It gives you control over the size and position of each subplot.
Read Matplotlib Change Background Color
Tips for Working with Multiple Plots in Matplotlib
- Always use
plt.tight_layout()to avoid overlapping titles and labels. - Label your axes clearly, especially when plots are next to each other.
- Use legends when plotting multiple lines on the same axes.
- Adjust figure size (
figsize) to make sure your plots are readable. - For large numbers of subplots, consider looping through axes objects to automate styling.
Creating multiple plots in Matplotlib is a fundamental skill that can greatly enhance your data analysis and reporting. Whether you’re comparing U.S. regional sales, visualizing unemployment trends, or overlaying temperature data, these methods provide the flexibility to present your data clearly.
By mastering subplot(), subplots(), overlaying multiple lines, and GridSpec, you’ll be able to handle almost any visualization scenario. I encourage you to try these examples with your datasets and see how multiple plots can make your insights more compelling.
Other Python Matplotlib you may like:

I am Bijay Kumar, a Microsoft MVP in SharePoint. Apart from SharePoint, I started working on Python, Machine learning, and artificial intelligence for the last 5 years. During this time I got expertise in various Python libraries also like Tkinter, Pandas, NumPy, Turtle, Django, Matplotlib, Tensorflow, Scipy, Scikit-Learn, etc… for various clients in the United States, Canada, the United Kingdom, Australia, New Zealand, etc. Check out my profile.