- 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
How to add annotations in Matplotlib Plots?
To specify the details of a plot, we use annotations. To create annotations in Matplotlib Plots, we can use the ‘annotate’ method.
Example
import matplotlib.pyplot as plt import numpy as np #Let us create a plot and use annotation at the point (5,3), x = np.arange(0,4*np.pi,0.1) plt.plot(np.sin(x), 'b-*') a = plt.annotate("(3,0)", xy=(3, 0), xycoords='data', xytext=(4.0,0.5), textcoords='data', arrowprops=dict(arrowstyle="->", color="green", lw=5, connectionstyle=("arc3,rad=0."))) plt.setp(a, size=25) #Display the plot plt.show()
Output
- Related Articles
- How does one insert statistical annotations (stars or p-values) into Matplotlib plots?
- How to reuse plots in Matplotlib?
- How to save Matplotlib 3d rotating plots?
- How to make semilogx and semilogy plots in Matplotlib?
- How to plot half or quarter polar plots in Matplotlib?
- Display two Sympy plots as one Matplotlib plot (add the second plot to the first)
- How to get multiple overlapping plots with independent scaling in Matplotlib?
- How to clear the memory completely of all Matplotlib plots?
- How to animate a time-ordered sequence of Matplotlib plots?
- How to merge two existing Matplotlib plots into one plot?
- Fixing color in scatter plots in Matplotlib
- How can Matplotlib be used to create multiple plots iteratively in Python?
- How to display print statements interlaced with Matplotlib plots inline in iPython?
- How to align multiple plots in a grid using GridSpec Class in Matplotlib
- Drawing lines between two plots in Matplotlib

Advertisements