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

Skip to content

Commit 9bd3c1e

Browse files
committed
adds section on annotating an artist using axes.annotate
1 parent 6ee6793 commit 9bd3c1e

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

tutorials/text/annotations.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,26 @@
9292

9393
# %%
9494
#
95+
# Annotating an Artist
96+
# ~~~~~~~~~~~~~~~~~~~~
97+
#
98+
# Annotations can be positioned relative to an artist by passing the artist
99+
# in as *xycoords*. Then *xy* is interpreted as a fraction of the artist's
100+
# boundingbox.
101+
102+
import matplotlib.patches as mpatches
103+
104+
fig, ax = plt.subplots(figsize=(3, 3))
105+
arr = mpatches.FancyArrowPatch((.25, .25), (.75, .75),
106+
arrowstyle='->,head_width=.15', mutation_scale=20)
107+
ax.add_patch(arr)
108+
ax.annotate("label", (.25, .25), xycoords=arr, ha='center', va='center')
109+
ax.set(xlim=(0, 1), ylim=(0, 1))
110+
111+
# %%
112+
# Here the annotion is placed at position (.25,.25) relative to the arrow's
113+
# lower left corner and is vertically and horzintally centered at that position.
114+
#
95115
# .. _annotation-with-arrow:
96116
#
97117
# Annotating with arrows

0 commit comments

Comments
 (0)