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

Skip to content

Commit 859d452

Browse files
committed
refactor arrow styles
- create arrow styles within subplots - allows for easy reshaping of the grid of arrow styles
1 parent 9026dba commit 859d452

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

scripts/annotation-arrow-styles.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,12 @@ def demo_con_style(ax, connectionstyle):
77
family="Source Code Pro",
88
transform=ax.transAxes, ha="left", va="top", size="x-small")
99

10-
fig, ax = plt.subplots(figsize=(4, 2.5), frameon=False)
11-
ax.axis("off")
12-
for i,style in enumerate(mpatches.ArrowStyle.get_styles()):
13-
x0, y0 = 5 + 5*(i%3), -(i//3)
14-
x1, y1 = 1 + 5*(i%3), -(i//3)
10+
(fig, axes) = plt.subplots(5, 3, figsize=(4, 2.5), frameon=False)
11+
for ax in axes.flatten():
12+
ax.axis("off")
13+
for i,(ax,style) in enumerate(zip(axes.flatten(), mpatches.ArrowStyle.get_styles())):
14+
x0, y0 = 0.8, 0.5
15+
x1, y1 = 0.2, 0.5
1516
ax.plot([x0, x1], [y0, y1], ".", color="0.25")
1617
ax.annotate("",
1718
xy=(x0, y0), xycoords='data',
@@ -22,6 +23,7 @@ def demo_con_style(ax, connectionstyle):
2223
patchA=None, patchB=None,
2324
connectionstyle="arc3,rad=0"))
2425
ax.text( (x1+x0)/2, y0-0.2, style,
26+
transform=ax.transAxes,
2527
family = "Source Code Pro", ha="center", va="top")
2628

2729
plt.savefig("../figures/annotation-arrow-styles.pdf")

0 commit comments

Comments
 (0)