To use pyplot.arrow or patches.Arrow() in matplotlib, we can take the following steps −
- Set the figure size and adjust the padding between and around the subplots.
- Initialize four variables, x_tail, y_tail, x_head and y_head.
- Create a figure and a set of subplots.
- Get a fancy arrow instance.
- Add an artist (step 4) using add_patch() method.
- To display the figure, use show() method.
Example
from matplotlib import pyplot as plt, patches as mpatches plt.rcParams["figure.figsize"] = [7.50, 3.50] plt.rcParams["figure.autolayout"] = True x_tail = 0.1 y_tail = 0.1 x_head = 0.9 y_head = 0.9 fig, ax = plt.subplots() arrow = mpatches.FancyArrowPatch((x_tail, y_tail), (x_head, y_head), mutation_scale=100, color='green') ax.add_patch(arrow) plt.show()