
- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Place text inside a circle in Matplotlib
To place text inside a circle in matplotlib, we can take the following steps −
Create a new figure or activate an existing figure using figure() method.
Add a subplot method to the current axis.
Create a Circle instance using Circle() class.
Add a circle path on the plot.
To place the text in the circle, we can use text() method.
Scale x and y axes using xlim() and ylim() methods.
To display the figure, use show() method.
Example
import matplotlib from matplotlib import pyplot as plt, patches plt.rcParams["figure.figsize"] = [7.00, 3.50] plt.rcParams["figure.autolayout"] = True fig = plt.figure() ax = fig.add_subplot(111) circle = matplotlib.patches.Circle((0, 0), radius=1, color='yellow') ax.add_patch(circle) plt.text(-.25, 0, "This is a Circle") plt.xlim([-4, 4]) plt.ylim([-4, 4]) plt.axis('equal') plt.show()
Output
- Related Questions & Answers
- Plot a circle inside a rectangle in Matplotlib
- How to plot a rectangle inside a circle in Matplotlib?
- How to add text inside a plot in Matplotlib?
- Check if a circle lies inside another circle or not in C++
- HTML5 Canvas Circle Text
- How to plot a circle in Matplotlib?
- Find if a point lies inside a Circle in C++
- Plot a circle with an edgecolor in Matplotlib
- Queries on count of points lie inside a circle in C++
- Create a text inside circles in HTML5 Canvas
- Add a caption text inside a thumbnail class
- Place the image at the bottom inside a Bootstrap 4 card
- Place the image at the top inside a Bootstrap 4 card
- Text alignment in a Matplotlib legend
- How can I place a table on a plot in Matplotlib?
Advertisements