- Trending Categories
- Data Structure
- Operating System
- C Programming
- 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 put text at the corner of an equal aspect figure in Python/Matplotlib?
To put text at the corner of an equal aspect figure in 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, using subplots() method.
Create x data points using numpy.
Plot x on axis ax1, using plot() method.
Plot x and 2*x on ax2, using plot() method.
To put text in the corner of a figure use annotate() method for different axes.
To display the figure, use show() method.
from matplotlib import pyplot as plt plt.rcParams["figure.figsize"] = [7.50, 3.50] plt.rcParams["figure.autolayout"] = True fig, axes = plt.subplots(2) x = np.linspace(-2, 2, 10) axes.plot(x) axes.plot(x, 2*x) for ax in axes: ax.annotate('Straight Line', xy=(1, 0),xycoords='axes fraction', fontsize=10, horizontalalignment='right', verticalalignment='bottom') plt.show()
- How to put the title at the bottom of a figure in Matplotlib?
- How to put the Origin at the center of the cos curve in a figure in Python Matplotlib?
- How to show (0,0) on matplotlib graph at the bottom left corner?
- How do I extend the margin at the bottom of a figure in Matplotlib?
- How to put text outside Python plots?
- How to set the margins of a Matplotlib figure?
- How to set the current figure in Matplotlib?
- Setting the aspect ratio of a 3D plot in Matplotlib
- How to change the aspect ratio of an image in JavaFX?
- Tkinter - How to put an outline on a canvas text
- How to draw axis in the middle of a figure in Matplotlib?
- How to maintain the aspect ratio of an element with CSS?
- Change figure size and figure format in Matplotlib
- How to autosize text in matplotlib Python?
- How to put a text in an image in OpenCV using C++?