- 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
Line plot with arrows in Matplotlib
To plot with arrows in matplotlib, we can use arrow() method.
- Create x and y data points using numpy.
- Plot x and y with color=red and linewidth = 1.
- Use arrow method to add an arrow to the axes. The first two values in the arguments are the coordinates of the arrow base and the next two values are for the length of the arrow along X and Y direction.
- To display the figure, use show() method.
from matplotlib import pyplot as plt import numpy as np plt.rcParams["figure.figsize"] = [7.00, 3.50] plt.rcParams["figure.autolayout"] = True x = np.linspace(-2, 2, 100) y = np.sin(x) plt.plot(x, y, c='b', lw=1) plt.arrow(0, 0, 0.01, np.sin(0.01), shape='full', lw=10, length_includes_head=True, head_width=.05, color='r') plt.show()
- How to plot a smooth line with matplotlib?
- How to annotate the points on a scatter plot with automatically placed arrows in Matplotlib?
- Plot a Line Graph for Pandas Dataframe with Matplotlib?
- How to plot a line (polygonal chain) with matplotlib with minimal smoothing?
- How to animate a line plot in Matplotlib?
- Plotting distance arrows in technical drawing in Matplotlib
- How to plot a gradient color line in matplotlib?
- How to plot a 3D continuous line in Matplotlib?
- Getting vertical gridlines to appear in line plot in matplotlib
- Legend with vertical line in matplotlib
- Plot numpy datetime64 with Matplotlib
- How to plot a line in Matplotlib with an interval at each data point?
- Plot Matplotlib 3D plot_surface with contour plot projection
- How to plot a line graph from histogram data in Matplotlib?
- Plot a multicolored line based on a condition in Python Matplotlib