|
13 | 13 | 'axes pixels' : pixels from lower left corner of axes |
14 | 14 | 'axes fraction' : 0,0 is lower left of axes and 1,1 is upper right |
15 | 15 | 'offset points' : Specify an offset (in points) from the xy value |
| 16 | + 'offset pixels' : Specify an offset (in pixels) from the xy value |
16 | 17 | 'data' : use the axes data coordinate system |
17 | 18 |
|
18 | 19 | Optionally, you can specify arrow properties which draws and arrow |
|
29 | 30 | any key for matplotlib.patches.polygon (e.g., facecolor) |
30 | 31 |
|
31 | 32 | For physical coordinate systems (points or pixels) the origin is the |
32 | | -(bottom, left) of the figure or axes. If the value is negative, |
33 | | -however, the origin is from the (right, top) of the figure or axes, |
34 | | -analogous to negative indexing of sequences. |
| 33 | +(bottom, left) of the figure or axes. |
35 | 34 | """ |
36 | 35 |
|
37 | 36 |
|
|
50 | 49 | s = np.cos(2*np.pi*t) |
51 | 50 | line, = ax.plot(t, s, lw=3, color='purple') |
52 | 51 |
|
53 | | - ax.annotate('axes center', xy=(.5, .5), xycoords='axes fraction', |
54 | | - horizontalalignment='center', verticalalignment='center') |
| 52 | + ax.annotate('figure pixels', |
| 53 | + xy=(10, 10), xycoords='figure pixels') |
55 | 54 |
|
56 | | - ax.annotate('pixels', xy=(20, 20), xycoords='figure pixels') |
| 55 | + ax.annotate('figure points', xy=(80, 80), |
| 56 | + xycoords='figure points') |
57 | 57 |
|
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', |
| 58 | + ax.annotate('point offset from data', xy=(2, 1), |
| 59 | + xycoords='data', |
| 60 | + xytext=(-15, 25), textcoords='offset points', |
62 | 61 | arrowprops=dict(facecolor='black', shrink=0.05), |
63 | 62 | horizontalalignment='right', verticalalignment='bottom', |
64 | 63 | ) |
65 | 64 |
|
66 | | - ax.annotate('local max', xy=(3, 1), xycoords='data', |
| 65 | + ax.annotate('axes fraction', xy=(3, 1), xycoords='data', |
67 | 66 | xytext=(0.8, 0.95), textcoords='axes fraction', |
68 | 67 | arrowprops=dict(facecolor='black', shrink=0.05), |
69 | 68 | horizontalalignment='right', verticalalignment='top', |
70 | 69 | ) |
71 | 70 |
|
72 | | - ax.annotate('a fractional title', xy=(.025, .975), |
| 71 | + ax.annotate('figure fraction', xy=(.025, .975), |
73 | 72 | xycoords='figure fraction', |
74 | 73 | horizontalalignment='left', verticalalignment='top', |
75 | 74 | fontsize=20) |
76 | 75 |
|
77 | 76 | # use negative points or pixels to specify from right, top -10, 10 |
78 | 77 | # is 10 points to the left of the right side of the axes and 10 |
79 | 78 | # 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) |
| 79 | + ax.annotate('pixel offset from axes fraction', xy=(1, 0), |
| 80 | + xycoords='axes fraction', |
| 81 | + xytext=(-20, 20), |
| 82 | + textcoords='offset pixels', |
| 83 | + horizontalalignment='right', |
| 84 | + verticalalignment='bottom') |
84 | 85 |
|
85 | 86 |
|
86 | 87 | if 1: |
|
0 commit comments