- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
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
Row and column headers in Matplotlib's subplots
Using the subplot method, we can configure the number of rows and columns. nrows*nclos will create number positions to draw a diagram.
Steps
Number of rows = 2, Number of columns = 1, so total locations are: 2*1 = 2.
Add a subplot to the current figure, nrow = 2, ncols = 1, index = 1.
Add a subplot to the current figure, nrow = 2, ncols = 1, index = 2.
Using plt.show(), we can show the figure.
Example
from matplotlib import pyplot as plt row_count = 2 col_count = 1 index1 = 1 # no. of subplots are: row*col, index is the position of figure. plt.subplot(row_count, col_count, index1) index2 = 2 plt.subplot(row_count, col_count, index2) plt.show()
Output
- Related Articles
- Animation using Matplotlib with subplots and ArtistAnimation
- Embedding small plots inside subplots in Matplotlib
- Manipulation on vertical space in Matplotlib subplots
- Manipulation on horizontal space in Matplotlib subplots
- Draw a border around subplots in Matplotlib
- Equivalent to matlab's imagesc in Matplotlib
- Populating Matplotlib subplots through a loop and a function
- Plotting grids across the subplots in Python Matplotlib
- How to zoom subplots together in Matplotlib/Pyplot?
- Putting arrowheads on vectors in Matplotlib's 3D plot
- Adjusting the heights of individual subplots in Matplotlib in Python
- How to update matplotlib's imshow() window interactively?
- How to share secondary Y-axis between subplots in Matplotlib?
- Setting the same axis limits for all subplots in Matplotlib
- Making matplotlib scatter plots from dataframes in Python's pandas

Advertisements