
- 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
How to draw a line outside of an axis in Matplotlib?
To draw a line (i.e., arrow) outside of an axis, we can use annotate() method,
Steps
Set the figure size and adjust the padding between and around the subplots.
Create a new figure or activate an existing figure using figure() method.
Clear the current figure.
Add an '~.axes.Axes' to the figure as part of a subplot arrangement using add_subplot() method.
Use annotate() method to place a line outside the axes.
To display the figure, use show() method.
Example
import matplotlib.pyplot as plt plt.rcParams["figure.figsize"] = [7.50, 3.50] plt.rcParams["figure.autolayout"] = True fig = plt.figure(1) fig.clf() ax = fig.add_subplot(1, 1, 1) ax.annotate('', xy=(0, -0.1), xycoords='axes fraction', xytext=(1, -0.1), arrowprops=dict(arrowstyle="<->", color='b')) plt.show()
Output
- Related Questions & Answers
- How to draw an average line for a scatter plot in MatPlotLib?
- How to draw axis in the middle of a figure in Matplotlib?
- How to draw axis lines inside a plot in Matplotlib?
- How to draw rounded line ends using Matplotlib?
- How can I draw a scatter trend line using Matplotlib?
- How can I draw inline line labels in Matplotlib?
- How to draw a line in Android?
- Draw a curve connecting two points instead of a straight line in matplotlib
- How to draw a line in HTML5 SVG?
- How to draw an arrowed line in OpenCV using Java?
- Draw a line on an image using OpenCV
- How to plot multiple Pandas columns on the Y-axis of a line graph (Matplotlib)?
- How to set the unit length of an axis in Matplotlib?
- How to set a Matplotlib rectangle edge to outside of specified width?
- How to draw a filled arc in Matplotlib?
Advertisements