- 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
Annotate Subplots in a Figure with A, B, C using Matplotlib
To annotate subplots in a figure with A, B and C using matplotlib, we can take the following steps
- Set the figure size and adjust the padding between and around the subplots.
- Create a figure and a set of subplots, with nrows=1 and ncols=3.
- Make a 1D iterator over an array.
- Iterate each axes and display data as an image.
- In the loop itself, place text A, B and C.
- To display the figure, use show() method.
Example
import numpy as np from matplotlib import pyplot as plt import string plt.rcParams["figure.figsize"] = [7.50, 3.50] plt.rcParams["figure.autolayout"] = True fig, axs = plt.subplots(1, 3) axs = axs.flat for index, ax in enumerate(axs): ax.imshow(np.random.randn(4, 4), interpolation='nearest', cmap="copper") ax.text(0.45, 1.1, string.ascii_uppercase[index], transform=ax.transAxes, size=20, weight='bold') plt.show()
Output
- Related Articles
- How to make more than 10 subplots in a figure using Matplotlib?
- Animation using Matplotlib with subplots and ArtistAnimation
- How to annotate a heatmap with text in Matplotlib?
- How to combine several matplotlib axes subplots into one figure?
- Draw a border around subplots in Matplotlib
- How to annotate several points with one text in Matplotlib?
- Annotate Time Series plot in Matplotlib
- Populating Matplotlib subplots through a loop and a function
- How to annotate the points on a scatter plot with automatically placed arrows in Matplotlib?
- How to annotate a range of the X-axis in Matplotlib?
- How to annotate the end of lines using Python and Matplotlib?
- How to set same scale for subplots in Python using Matplotlib?
- How to increase the spacing between subplots in Matplotlib with subplot2grid?
- Embedding small plots inside subplots in Matplotlib
- Manipulation on vertical space in Matplotlib subplots

Advertisements