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

Skip to content

Commit 14db9f8

Browse files
committed
DOC: improve annotation demo
closes #5994
1 parent 5bad764 commit 14db9f8

File tree

1 file changed

+15
-13
lines changed

1 file changed

+15
-13
lines changed

examples/pylab_examples/annotation_demo.py

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -50,37 +50,39 @@
5050
s = np.cos(2*np.pi*t)
5151
line, = ax.plot(t, s, lw=3, color='purple')
5252

53-
ax.annotate('axes center', xy=(.5, .5), xycoords='axes fraction',
54-
horizontalalignment='center', verticalalignment='center')
53+
ax.annotate('figure pixels',
54+
xy=(10, 10), xycoords='figure pixels')
5555

56-
ax.annotate('pixels', xy=(20, 20), xycoords='figure pixels')
56+
ax.annotate('figure points', xy=(80, 80),
57+
xycoords='figure points')
5758

58-
ax.annotate('points', xy=(100, 300), xycoords='figure points')
59-
60-
ax.annotate('offset', xy=(1, 1), xycoords='data',
61-
xytext=(-15, 10), textcoords='offset points',
59+
ax.annotate('point offset from data', xy=(2, 1),
60+
xycoords='data',
61+
xytext=(-15, 25), textcoords='offset points',
6262
arrowprops=dict(facecolor='black', shrink=0.05),
6363
horizontalalignment='right', verticalalignment='bottom',
6464
)
6565

66-
ax.annotate('local max', xy=(3, 1), xycoords='data',
66+
ax.annotate('axes fraction', xy=(3, 1), xycoords='data',
6767
xytext=(0.8, 0.95), textcoords='axes fraction',
6868
arrowprops=dict(facecolor='black', shrink=0.05),
6969
horizontalalignment='right', verticalalignment='top',
7070
)
7171

72-
ax.annotate('a fractional title', xy=(.025, .975),
72+
ax.annotate('figure fraction', xy=(.025, .975),
7373
xycoords='figure fraction',
7474
horizontalalignment='left', verticalalignment='top',
7575
fontsize=20)
7676

7777
# use negative points or pixels to specify from right, top -10, 10
7878
# is 10 points to the left of the right side of the axes and 10
7979
# points above the bottom
80-
ax.annotate('bottom right (points)', xy=(-10, 10),
81-
xycoords='axes points',
82-
horizontalalignment='right', verticalalignment='bottom',
83-
fontsize=20)
80+
ax.annotate('pixel offset from axes fraction', xy=(1, 0),
81+
xycoords='axes fraction',
82+
xytext=(-20, 20),
83+
textcoords='offset pixels',
84+
horizontalalignment='right',
85+
verticalalignment='bottom')
8486

8587

8688
if 1:

0 commit comments

Comments
 (0)