|
11 | 11 | import matplotlib.pyplot as plt |
12 | 12 |
|
13 | 13 |
|
| 14 | +ROOT_DIR = pathlib.Path(__file__).parent.parent |
| 15 | + |
14 | 16 | mpl.style.use([ |
15 | | - pathlib.Path(__file__).parent/'../styles/base.mplstyle', |
16 | | - pathlib.Path(__file__).parent/'../styles/plotlet.mplstyle', |
| 17 | + ROOT_DIR / 'styles/base.mplstyle', |
| 18 | + ROOT_DIR / 'styles/plotlet.mplstyle', |
17 | 19 | ]) |
18 | 20 |
|
19 | 21 |
|
|
29 | 31 | Y = 4 + 2*np.sin(2*X) |
30 | 32 | ax.plot(X, Y, color="C1") |
31 | 33 | ax.grid() |
32 | | -fig.savefig("../figures/basic-plot.pdf") |
| 34 | +fig.savefig(ROOT_DIR / "figures/basic-plot.pdf") |
33 | 35 |
|
34 | 36 | # Basic line plot (color) |
35 | 37 | # ----------------------------------------------------------------------------- |
|
38 | 40 | Y = 4 + 2*np.sin(2*X) |
39 | 41 | ax.plot(X, Y, color="black") |
40 | 42 | ax.grid() |
41 | | -fig.savefig("../figures/basic-plot-color.pdf") |
| 43 | +fig.savefig(ROOT_DIR / "figures/basic-plot-color.pdf") |
42 | 44 |
|
43 | 45 | # Basic scatter plot |
44 | 46 | # ----------------------------------------------------------------------------- |
|
49 | 51 | ax.scatter(X, Y, 5, zorder=10, |
50 | 52 | edgecolor="white", facecolor="C1", linewidth=0.25) |
51 | 53 | ax.grid() |
52 | | -fig.savefig("../figures/basic-scatter.pdf") |
| 54 | +fig.savefig(ROOT_DIR / "figures/basic-scatter.pdf") |
53 | 55 |
|
54 | 56 | # Basic bar plot |
55 | 57 | # ----------------------------------------------------------------------------- |
|
61 | 63 | edgecolor="white", facecolor="C1", linewidth=0.25) |
62 | 64 | ax.set_axisbelow(True) |
63 | 65 | ax.grid() |
64 | | -fig.savefig("../figures/basic-bar.pdf") |
| 66 | +fig.savefig(ROOT_DIR / "figures/basic-bar.pdf") |
65 | 67 |
|
66 | 68 | # Basic imshow plot |
67 | 69 | # ----------------------------------------------------------------------------- |
|
72 | 74 | Z[..., 3] = np.random.uniform(0.25, 1.0, (8, 8)) |
73 | 75 | ax.imshow(Z, extent=[0, 8, 0, 8], interpolation="nearest") |
74 | 76 | ax.grid(linewidth=0.25, color="white") |
75 | | -fig.savefig("../figures/basic-imshow.pdf") |
| 77 | +fig.savefig(ROOT_DIR / "figures/basic-imshow.pdf") |
76 | 78 |
|
77 | 79 | # Basic pcolormesh plot |
78 | 80 | # ----------------------------------------------------------------------------- |
|
84 | 86 | plt.pcolormesh(X, Y, Z, cmap='Oranges', shading='auto') |
85 | 87 | ax.set_xlim(-3, 3), ax.set_xticks(np.arange(-3, 4)) |
86 | 88 | ax.set_ylim(-3, 3), ax.set_yticks(np.arange(-3, 4)) |
87 | | -fig.savefig("../figures/basic-pcolormesh.pdf") |
| 89 | +fig.savefig(ROOT_DIR / "figures/basic-pcolormesh.pdf") |
88 | 90 |
|
89 | 91 | # Basic contour plot |
90 | 92 | # ----------------------------------------------------------------------------- |
|
95 | 97 | plt.contourf(Z, len(colors), extent=[0, 8, 0, 8], colors=colors) |
96 | 98 | plt.contour(Z, len(colors), extent=[0, 8, 0, 8], colors="white", |
97 | 99 | linewidths=0.125, nchunk=10) |
98 | | -fig.savefig("../figures/basic-contour.pdf") |
| 100 | +fig.savefig(ROOT_DIR / "figures/basic-contour.pdf") |
99 | 101 |
|
100 | 102 | # Basic pie plot |
101 | 103 | # ----------------------------------------------------------------------------- |
|
110 | 112 | wedgeprops={"linewidth": 0.25, "edgecolor": "white"}, frame=True) |
111 | 113 | ax.pie(X, colors=colors, radius=3, center=(4, 4), |
112 | 114 | wedgeprops={"linewidth": 0.25, "edgecolor": "white"}, frame=True) |
113 | | -fig.savefig("../figures/basic-pie.pdf") |
| 115 | +fig.savefig(ROOT_DIR / "figures/basic-pie.pdf") |
114 | 116 |
|
115 | 117 | # Basic text plot |
116 | 118 | # ----------------------------------------------------------------------------- |
|
119 | 121 | ax.grid(linewidth=0.25, color="0.75") |
120 | 122 | ax.text(4, 4, "TEXT", color="C1", size=8, weight="bold", |
121 | 123 | ha="center", va="center", rotation=25) |
122 | | -fig.savefig("../figures/basic-text.pdf") |
| 124 | +fig.savefig(ROOT_DIR / "figures/basic-text.pdf") |
123 | 125 |
|
124 | 126 | # Basic fill plot |
125 | 127 | # ----------------------------------------------------------------------------- |
|
132 | 134 | plt.plot(X, (Y1+Y2)/2, color="C1", linewidth=0.5) |
133 | 135 | ax.set_axisbelow(True) |
134 | 136 | ax.grid(color="0.75") |
135 | | -fig.savefig("../figures/basic-fill.pdf") |
| 137 | +fig.savefig(ROOT_DIR / "figures/basic-fill.pdf") |
136 | 138 |
|
137 | 139 | # Basic quiver plot |
138 | 140 | # ----------------------------------------------------------------------------- |
|
145 | 147 | angles='xy', scale_units='xy', scale=0.5, width=.05) |
146 | 148 | ax.set_axisbelow(True) |
147 | 149 | ax.grid(color="0.75") |
148 | | -fig.savefig("../figures/basic-quiver.pdf") |
| 150 | +fig.savefig(ROOT_DIR / "figures/basic-quiver.pdf") |
0 commit comments