- Notifications
You must be signed in to change notification settings - Fork 908
/
Copy pathtip-post-processing.py
32 lines (26 loc) · 1.1 KB
/
tip-post-processing.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
importpathlib
importnumpyasnp
importmatplotlib.pyplotasplt
frommatplotlib.figureimportFigure
frommatplotlib.backends.backend_aggimportFigureCanvas
fromscipy.ndimageimportgaussian_filter
ROOT_DIR=pathlib.Path(__file__).parent.parent
# First pass for drop-shadow
fig=Figure(figsize=(6, 1.5))
canvas=FigureCanvas(fig)
ax=fig.add_axes([0, 0, 1, 1], frameon=False,
xlim=[0, 1], xticks=[], ylim=[0, 1], yticks=[])
ax.text(0.5, 0.5, "Matplotlib", transform=ax.transAxes,
ha="center", va="center", size=64, color="black")
canvas.draw()
Z=np.array(canvas.renderer.buffer_rgba())[:, :, 0]
Z=gaussian_filter(Z, sigma=9)
# Second pass for text + drop-shadow
fig=plt.figure(figsize=(6, 1.5))
ax=fig.add_axes([0, 0, 1, 1], frameon=False,
xlim=[0, 1], xticks=[], ylim=[0, 1], yticks=[])
ax.imshow(Z, extent=[0, 1, 0, 1], cmap=plt.cm.gray, alpha=0.65, aspect='auto')
ax.text(0.5, 0.5, "Matplotlib", transform=ax.transAxes,
ha="center", va="center", size=64, color="black")
fig.savefig(ROOT_DIR/"figures/tip-post-processing.pdf", dpi=600)
# plt.show()