1"""
2=================
3Simple Annotate01
4=================
5
6"""
7
8import matplotlib.pyplot as plt
9import matplotlib.patches as mpatches
10
11
12fig, axs = plt.subplots(2, 4)
13x1, y1 = 0.3, 0.3
14x2, y2 = 0.7, 0.7
15
16ax = axs.flat[0]
17ax.plot([x1, x2], [y1, y2], "o")
18ax.annotate("",
19            xy=(x1, y1), xycoords='data',
20            xytext=(x2, y2), textcoords='data',
21            arrowprops=dict(arrowstyle="->"))
22ax.text(.05, .95, "A $->$ B", transform=ax.transAxes, ha="left", va="top")
23
24ax = axs.flat[2]
25ax.plot([x1, x2], [y1, y2], "o")
26ax.annotate("",
27            xy=(x1, y1), xycoords='data',
28            xytext=(x2, y2), textcoords='data',
29            arrowprops=dict(arrowstyle="->", connectionstyle="arc3,rad=0.3",
30                            shrinkB=5)
31            )
32ax.text(.05, .95, "shrinkB=5", transform=ax.transAxes, ha="left", va="top")
33
34ax = axs.flat[3]
35ax.plot([x1, x2], [y1, y2], "o")
36ax.annotate("",
37            xy=(x1, y1), xycoords='data',
38            xytext=(x2, y2), textcoords='data',
39            arrowprops=dict(arrowstyle="->", connectionstyle="arc3,rad=0.3"))
40ax.text(.05, .95, "connectionstyle=arc3", transform=ax.transAxes, ha="left", va="top")
41
42ax = axs.flat[4]
43ax.plot([x1, x2], [y1, y2], "o")
44el = mpatches.Ellipse((x1, y1), 0.3, 0.4, angle=30, alpha=0.5)
45ax.add_artist(el)
46ax.annotate("",
47            xy=(x1, y1), xycoords='data',
48            xytext=(x2, y2), textcoords='data',
49            arrowprops=dict(arrowstyle="->", connectionstyle="arc3,rad=0.2")
50            )
51
52ax = axs.flat[5]
53ax.plot([x1, x2], [y1, y2], "o")
54el = mpatches.Ellipse((x1, y1), 0.3, 0.4, angle=30, alpha=0.5)
55ax.add_artist(el)
56ax.annotate("",
57            xy=(x1, y1), xycoords='data',
58            xytext=(x2, y2), textcoords='data',
59            arrowprops=dict(arrowstyle="->", connectionstyle="arc3,rad=0.2",
60                            patchB=el)
61            )
62ax.text(.05, .95, "patchB", transform=ax.transAxes, ha="left", va="top")
63
64ax = axs.flat[6]
65ax.plot([x1], [y1], "o")
66ax.annotate("Test",
67            xy=(x1, y1), xycoords='data',
68            xytext=(x2, y2), textcoords='data',
69            ha="center", va="center",
70            bbox=dict(boxstyle="round", fc="w"),
71            arrowprops=dict(arrowstyle="->")
72            )
73ax.text(.05, .95, "annotate", transform=ax.transAxes, ha="left", va="top")
74
75ax = axs.flat[7]
76ax.plot([x1], [y1], "o")
77ax.annotate("Test",
78            xy=(x1, y1), xycoords='data',
79            xytext=(x2, y2), textcoords='data',
80            ha="center", va="center",
81            bbox=dict(boxstyle="round", fc="w", ),
82            arrowprops=dict(arrowstyle="->", relpos=(0., 0.))
83            )
84ax.text(.05, .95, "relpos=(0,0)", transform=ax.transAxes, ha="left", va="top")
85
86for ax in axs.flat:
87    ax.set(xlim=(0, 1), ylim=(0, 1), xticks=[], yticks=[], aspect=1)
88
89plt.show()
90