<jupyter_start><jupyter_text>Arrow guideAdding arrow patches to plots.Arrows are often used to annotate plots. This tutorial shows how to plot arrowsthat behave differently when the data limits on a plot are changed. In general,points on a plot can either be fixed in "data space" or "display space".Something plotted in data space moves when the data limits are altered - anexample would the points in a scatter plot. Something plotted in display spacestays static when data limits are altered - an example would be a figure titleor the axis labels.Arrows consist of a head (and possibly a tail) and a stem drawn between astart point and end point, called 'anchor points' from now on.Here we show three use cases for plotting arrows, depending on whether thehead or anchor points need to be fixed in data or display space:    1. Head shape fixed in display space, anchor points fixed in data space    2. Head shape and anchor points fixed in display space    3. Entire patch fixed in data spaceBelow each use case is presented in turn.<jupyter_code>import matplotlib.patches as mpatches
import matplotlib.pyplot as plt
x_tail = 0.1
y_tail = 0.1
x_head = 0.9
y_head = 0.9
dx = x_head - x_tail
dy = y_head - y_tail<jupyter_output><empty_output><jupyter_text>Head shape fixed in display space and anchor points fixed in data space-----------------------------------------------------------------------This is useful if you are annotating a plot, and don't want the arrow toto change shape or position if you pan or scale the plot. Note that whenthe axis limits changeIn this case we use `.patches.FancyArrowPatch`Note that when the axis limits are changed, the arrow shape stays the same,but the anchor points move.<jupyter_code>fig, axs = plt.subplots(nrows=2)
arrow = mpatches.FancyArrowPatch((x_tail, y_tail), (dx, dy),
                                 mutation_scale=100)
axs[0].add_patch(arrow)

arrow = mpatches.FancyArrowPatch((x_tail, y_tail), (dx, dy),
                                 mutation_scale=100)
axs[1].add_patch(arrow)
axs[1].set_xlim(0, 2)
axs[1].set_ylim(0, 2)<jupyter_output><empty_output><jupyter_text>Head shape and anchor points fixed in display space---------------------------------------------------This is useful if you are annotating a plot, and don't want the arrow toto change shape or position if you pan or scale the plot.In this case we use `.patches.FancyArrowPatch`, and pass the keyword argument``transform=ax.transAxes`` where ``ax`` is the axes we are adding the patchto.Note that when the axis limits are changed, the arrow shape and locationstays the same.<jupyter_code>fig, axs = plt.subplots(nrows=2)
arrow = mpatches.FancyArrowPatch((x_tail, y_tail), (dx, dy),
                                 mutation_scale=100,
                                 transform=axs[0].transAxes)
axs[0].add_patch(arrow)

arrow = mpatches.FancyArrowPatch((x_tail, y_tail), (dx, dy),
                                 mutation_scale=100,
                                 transform=axs[1].transAxes)
axs[1].add_patch(arrow)
axs[1].set_xlim(0, 2)
axs[1].set_ylim(0, 2)<jupyter_output><empty_output><jupyter_text>Head shape and anchor points fixed in data space------------------------------------------------In this case we use `.patches.Arrow`Note that when the axis limits are changed, the arrow shape and locationchanges.<jupyter_code>fig, axs = plt.subplots(nrows=2)

arrow = mpatches.Arrow(x_tail, y_tail, dx, dy)
axs[0].add_patch(arrow)

arrow = mpatches.Arrow(x_tail, y_tail, dx, dy)
axs[1].add_patch(arrow)
axs[1].set_xlim(0, 2)
axs[1].set_ylim(0, 2)
plt.show()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.12275366325684268, 'fraction_numerical': 0.014376555156206802, 'mean_word_length': 3.1730103806228374, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '4', 'dir': 'jupyter-structured-clean-dedup', 'id': '52740', 'license': 'MIT', 'n_tokens_mistral': 1100, 'n_tokens_neox': 1070, 'n_words': 409, 'path': 'matplotlib/gallery_jupyter/shapes_and_collections/arrow_guide.ipynb', 'repo_name': 'kingreatwill/penter', 'size': '3617'}