|
19 | 19 | nrow= (len(styles)+1)//ncol
|
20 | 20 | axs= (plt.figure(figsize=(4*ncol,1+nrow))
|
21 | 21 | .add_gridspec(1+nrow,ncol,
|
22 |
| -wspace=.7,left=.1,right=.9,bottom=0,top=1).subplots()) |
| 22 | +wspace=0,hspace=0,left=0,right=1,bottom=0,top=1).subplots()) |
23 | 23 | foraxinaxs.flat:
|
| 24 | +ax.set_xlim(-0.5,4) |
24 | 25 | ax.set_axis_off()
|
25 | 26 | foraxinaxs[0, :]:
|
26 |
| -ax.text(0,.5,"arrowstyle", |
27 |
| -transform=ax.transAxes,size="large",color="tab:blue", |
28 |
| -horizontalalignment="center",verticalalignment="center") |
29 |
| -ax.text(.35,.5,"default parameters", |
30 |
| -transform=ax.transAxes, |
31 |
| -horizontalalignment="left",verticalalignment="center") |
| 27 | +ax.text(-0.25,0.5,"arrowstyle",size="large",color="tab:blue") |
| 28 | +ax.text(1.25,.5,"default parameters",size="large") |
32 | 29 | forax, (stylename,stylecls)inzip(axs[1:, :].T.flat,styles.items()):
|
33 |
| -l,=ax.plot(.25,.5,"ok",transform=ax.transAxes) |
34 |
| -ax.annotate(stylename, (.25,.5), (-0.1,.5), |
35 |
| -xycoords="axes fraction",textcoords="axes fraction", |
36 |
| -size="large",color="tab:blue", |
37 |
| -horizontalalignment="center",verticalalignment="center", |
| 30 | +# draw dot and annotation with arrowstyle |
| 31 | +l,=ax.plot(1,0,"o",color="grey") |
| 32 | +ax.annotate(stylename, (1,0), (0,0), |
| 33 | +size="large",color="tab:blue",ha="center",va="center", |
38 | 34 | arrowprops=dict(
|
39 | 35 | arrowstyle=stylename,connectionstyle="arc3,rad=-0.05",
|
40 | 36 | color="k",shrinkA=5,shrinkB=5,patchB=l,
|
41 | 37 | ),
|
42 |
| -bbox=dict(boxstyle="square",fc="w")) |
| 38 | +bbox=dict(boxstyle="square",fc="w",ec="grey")) |
| 39 | +# draw default parameters |
43 | 40 | # wrap at every nth comma (n = 1 or 2, depending on text length)
|
44 | 41 | s=str(inspect.signature(stylecls))[1:-1]
|
45 | 42 | n=2ifs.count(',')>3else1
|
46 |
| -ax.text(.35,.5, |
| 43 | +ax.text(1.25,0, |
47 | 44 | re.sub(', ',lambdam,c=itertools.count(1):m.group()
|
48 | 45 | ifnext(c)%nelse'\n',s),
|
49 |
| -transform=ax.transAxes, |
50 |
| -horizontalalignment="left",verticalalignment="center") |
| 46 | +verticalalignment="center") |
51 | 47 |
|
52 | 48 | plt.show()
|
53 | 49 |
|
|