|
| 1 | +import matplotlib.patches as mpatch |
| 2 | +import matplotlib.pyplot as plt |
| 3 | + |
| 4 | +figheight = 8 |
| 5 | +fig = plt.figure(1, figsize=(9, figheight), dpi=80) |
| 6 | +fontsize = 0.4 * fig.dpi |
| 7 | + |
| 8 | +def make_boxstyles(ax): |
| 9 | + styles = mpatch.BoxStyle.get_styles() |
| 10 | + |
| 11 | + for i, (stylename, styleclass) in enumerate(styles.items()): |
| 12 | + ax.text(0.5, (float(len(styles)) - 0.5 - i)/len(styles), stylename, |
| 13 | + ha="center", |
| 14 | + size=fontsize, |
| 15 | + transform=ax.transAxes, |
| 16 | + bbox=dict(boxstyle=stylename, fc="w", ec="k")) |
| 17 | + |
| 18 | +def make_arrowstyles(ax): |
| 19 | + styles = mpatch.ArrowStyle.get_styles() |
| 20 | + |
| 21 | + ax.set_xlim(0, 4) |
| 22 | + ax.set_ylim(0, figheight) |
| 23 | + |
| 24 | + for i, (stylename, styleclass) in enumerate(sorted(styles.items())): |
| 25 | + y = (float(len(styles)) -0.25 - i) # /figheight |
| 26 | + p = mpatch.Circle((3.2, y), 0.2, fc="w") |
| 27 | + ax.add_patch(p) |
| 28 | + |
| 29 | + ax.annotate(stylename, (3.2, y), |
| 30 | + (2., y), |
| 31 | + #xycoords="figure fraction", textcoords="figure fraction", |
| 32 | + ha="right", va="center", |
| 33 | + size=fontsize, |
| 34 | + arrowprops=dict(arrowstyle=stylename, |
| 35 | + patchB=p, |
| 36 | + shrinkA=5, |
| 37 | + shrinkB=5, |
| 38 | + fc="w", ec="k", |
| 39 | + connectionstyle="arc3,rad=-0.05", |
| 40 | + ), |
| 41 | + bbox=dict(boxstyle="square", fc="w")) |
| 42 | + |
| 43 | + ax.xaxis.set_visible(False) |
| 44 | + ax.yaxis.set_visible(False) |
| 45 | + |
| 46 | + |
| 47 | +ax1 = fig.add_subplot(121, frameon=False, xticks=[], yticks=[]) |
| 48 | +make_boxstyles(ax1) |
| 49 | + |
| 50 | +ax2 = fig.add_subplot(122, frameon=False, xticks=[], yticks=[]) |
| 51 | +make_arrowstyles(ax2) |
| 52 | + |
| 53 | + |
| 54 | +plt.show() |
0 commit comments