Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit bf248b9

Browse files
author
Tim Hoffmann
committed
Modify "Annotating an Artist" of Annotations tutorial
to a horizontal arrow so that the arrow line does not cross the artist. This is somewhat special but visually more pleasing and possibly a real use case.
1 parent 4b42d7f commit bf248b9

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

galleries/users_explain/text/annotations.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -113,16 +113,17 @@
113113
import matplotlib.patches as mpatches
114114

115115
fig, ax = plt.subplots(figsize=(3, 3))
116-
arr = mpatches.FancyArrowPatch((1.25, 1.25), (1.75, 1.75),
116+
arr = mpatches.FancyArrowPatch((1.25, 1.5), (1.75, 1.5),
117117
arrowstyle='->,head_width=.15', mutation_scale=20)
118118
ax.add_patch(arr)
119-
ax.annotate("label", (.5, .5), xycoords=arr, ha='center', va='center')
119+
ax.annotate("label", (.5, .5), xycoords=arr, ha='center', va='bottom')
120120
ax.set(xlim=(1, 2), ylim=(1, 2))
121121

122122
# %%
123123
# Here the annotation is placed at position (.5,.5) relative to the arrow's
124-
# lower left corner and is vertically and horizontally centered at that
125-
# position. For an example of chaining annotation Artists, see the
124+
# lower left corner and is vertically and horizontally at that position.
125+
# Vertically, the bottom aligns to that reference point so that the label
126+
# is above the line. For an example of chaining annotation Artists, see the
126127
# :ref:`Artist section <artist_annotation_coord>` of
127128
# :ref:`annotating_coordinate_systems`.
128129
#

0 commit comments

Comments
 (0)