- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to make several plots on a single page using Matplotlib(Python)?
Using plt.figure(), we can create a figure and can split that in parts using subplot(221) methods, where nrows=2, nlos=2, and (1,2,3,4) represent the index position.
Steps
Create a new figure, or activate an existing figure, using figure() method.
Add a subplot to the current figure, using subplot() method, where nrows = 2, ncols = 2 and index = 1.
Add a subplot to the current figure, using subplot() method, where nrows = 2, ncols = 2 and index = 2.
Add a subplot to the current figure, using subplot() method, where nrows = 2, ncols = 2 and index = 3.
Add a subplot to the current figure, using subplot() method, where nrows = 2, ncols = 2 and index = 4
To show the figure, we can use plt.show() method.
Example
from matplotlib import pyplot as plt fig = plt.figure() plt.subplot(221) plt.subplot(222) plt.subplot(223) plt.subplot(224) plt.show()
Output
- Related Articles
- How to make several plots on a single page using Matplotlib?
- How to make several plots on a single page using matplotlib in Python?
- How to make semilogx and semilogy plots in Matplotlib?
- How to make two plots side-by-side using Python?
- How to make several legend keys to the same entry in Matplotlib?
- How can Matplotlib be used to three-dimensional line plots using Python?
- How to make a page redirect using jQuery?
- How to make colorbar orientation horizontal in Python using Matplotlib?
- How do I show the same Matplotlib figure several times in a single IPython notebook?
- How to reuse plots in Matplotlib?
- How to Annotate Matplotlib Scatter Plots?
- How to add multiple graphs to a Plotly Dash app on a single browser page in Python Plotly?
- How to save multiple plots into a single HTML file in Python Plotly?
- How can multiple plots be plotted in same figure using matplotlib and Python?
- How to align multiple plots in a grid using GridSpec Class in Matplotlib

Advertisements