|
8 | 8 | import matplotlib.pyplot as plt |
9 | 9 | plt.rcParams.update({ |
10 | 10 | "font.family": "serif", |
11 | | - "font.serif": [], # use latex default serif font |
12 | | - "font.sans-serif": ["DejaVu Sans"], # use a specific sans-serif font |
| 11 | + # Use LaTeX default serif font. |
| 12 | + "font.serif": [], |
| 13 | + # Use specific cursive fonts. |
| 14 | + "font.cursive": ["Comic Neue", "Comic Sans MS"], |
13 | 15 | }) |
14 | 16 |
|
15 | | -plt.figure(figsize=(4.5, 2.5)) |
16 | | -plt.plot(range(5)) |
17 | | -plt.text(0.5, 3., "serif") |
18 | | -plt.text(0.5, 2., "monospace", family="monospace") |
19 | | -plt.text(2.5, 2., "sans-serif", family="sans-serif") |
20 | | -plt.text(2.5, 1., "comic sans", family="Comic Sans MS") |
21 | | -plt.xlabel("µ is not $\\mu$") |
22 | | -plt.tight_layout(.5) |
| 17 | +fig, ax = plt.subplots(figsize=(4.5, 2.5)) |
23 | 18 |
|
24 | | -plt.savefig("pgf_fonts.pdf") |
25 | | -plt.savefig("pgf_fonts.png") |
| 19 | +ax.plot(range(5)) |
| 20 | + |
| 21 | +ax.text(0.5, 3., "serif") |
| 22 | +ax.text(0.5, 2., "monospace", family="monospace") |
| 23 | +ax.text(2.5, 2., "sans-serif", family="DejaVu Sans") # Use specific sans font. |
| 24 | +ax.text(2.5, 1., "comic", family="cursive") |
| 25 | +ax.set_xlabel("µ is not $\\mu$") |
| 26 | + |
| 27 | +fig.tight_layout(pad=.5) |
| 28 | + |
| 29 | +fig.savefig("pgf_fonts.pdf") |
| 30 | +fig.savefig("pgf_fonts.png") |
0 commit comments