-
Notifications
You must be signed in to change notification settings - Fork 906
/
Copy pathannotation-arrow-styles.py
38 lines (29 loc) · 1.26 KB
/
annotation-arrow-styles.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import pathlib
import matplotlib.pyplot as plt
import matplotlib.patches as mpatches
ROOT_DIR = pathlib.Path(__file__).parent.parent
styles = mpatches.ArrowStyle.get_styles()
def demo_con_style(ax, connectionstyle):
ax.text(.05, .95, connectionstyle.replace(",", ",\n"),
family="Source Code Pro",
transform=ax.transAxes, ha="left", va="top", size="x-small")
(fig, axes) = plt.subplots(4, 4, figsize=(4, 2.5), frameon=False)
for ax in axes.flatten():
ax.axis("off")
for i, (ax, style) in enumerate(zip(axes.flatten(), mpatches.ArrowStyle.get_styles())):
x0, y0 = 0.8, 0.5
x1, y1 = 0.2, 0.5
ax.plot([x0, x1], [y0, y1], ".", color="0.25")
ax.annotate("",
xy=(x0, y0), xycoords='data',
xytext=(x1, y1), textcoords='data',
arrowprops=dict(arrowstyle=style,
color="black",
shrinkA=5, shrinkB=5,
patchA=None, patchB=None,
connectionstyle="arc3,rad=0"))
ax.text( (x1+x0)/2, y0-0.2, style,
transform=ax.transAxes,
family="Source Code Pro", ha="center", va="top")
fig.savefig(ROOT_DIR / "figures/annotation-arrow-styles.pdf")
# plt.show()