|
| 1 | +import matplotlib.pyplot as plt |
| 2 | + |
| 3 | +def demo_con_style(ax, connectionstyle): |
| 4 | + x1, y1 = 0.3, 0.2 |
| 5 | + x2, y2 = 0.8, 0.6 |
| 6 | + ax.plot([x1, x2], [y1, y2], ".") |
| 7 | + ax.annotate("", |
| 8 | + xy=(x1, y1), xycoords='data', |
| 9 | + xytext=(x2, y2), textcoords='data', |
| 10 | + arrowprops=dict(arrowstyle="->", color="0.5", |
| 11 | + shrinkA=5, shrinkB=5, |
| 12 | + patchA=None, patchB=None, |
| 13 | + connectionstyle=connectionstyle), |
| 14 | + ) |
| 15 | + ax.text(.05, .95, connectionstyle.replace(",", ",\n"), |
| 16 | + family="Source Code Pro", |
| 17 | + transform=ax.transAxes, ha="left", va="top", size="x-small") |
| 18 | + |
| 19 | +fig, axs = plt.subplots(3, 3, figsize=(5, 5)) |
| 20 | +demo_con_style(axs[0, 0], "arc3,rad=0") |
| 21 | +demo_con_style(axs[0, 1], "arc3,rad=0.3") |
| 22 | +demo_con_style(axs[0, 2], "angle3,angleA=0,angleB=90") |
| 23 | +demo_con_style(axs[1, 0], "angle,angleA=-90,angleB=180,rad=0") |
| 24 | +demo_con_style(axs[1, 1], "angle,angleA=-90,angleB=180,rad=25") |
| 25 | +demo_con_style(axs[1, 2], "arc,angleA=-90,angleB=0,armA=0,armB=40,rad=0") |
| 26 | +demo_con_style(axs[2, 0], "bar,fraction=0.3") |
| 27 | +demo_con_style(axs[2, 1], "bar,fraction=-0.3") |
| 28 | +demo_con_style(axs[2, 2], "bar,angle=180,fraction=-0.2") |
| 29 | + |
| 30 | +for ax in axs.flat: |
| 31 | + ax.set(xlim=(0, 1), ylim=(0, 1), xticks=[], yticks=[], aspect=1) |
| 32 | +fig.tight_layout(pad=0.2) |
| 33 | + |
| 34 | +plt.savefig("../figures/annotation-connection-styles.pdf") |
| 35 | +# plt.show() |
0 commit comments