|
11 | 11 | from matplotlib.font_manager import FontProperties
|
12 | 12 | import matplotlib.pyplot as plt
|
13 | 13 |
|
14 |
| -font0 = FontProperties() |
| 14 | +fig = plt.figure() |
15 | 15 | alignment = {'horizontalalignment': 'center', 'verticalalignment': 'baseline'}
|
16 |
| -# Show family options |
17 |
| - |
18 |
| -families = ['serif', 'sans-serif', 'cursive', 'fantasy', 'monospace'] |
19 |
| - |
20 |
| -font1 = font0.copy() |
21 |
| -font1.set_size('large') |
22 |
| - |
23 |
| -t = plt.figtext(0.1, 0.9, 'family', fontproperties=font1, **alignment) |
24 |
| - |
25 | 16 | yp = [0.8, 0.7, 0.6, 0.5, 0.4, 0.3, 0.2]
|
| 17 | +heading_font = FontProperties(size='large') |
26 | 18 |
|
| 19 | +# Show family options |
| 20 | +fig.text(0.1, 0.9, 'family', fontproperties=heading_font, **alignment) |
| 21 | +families = ['serif', 'sans-serif', 'cursive', 'fantasy', 'monospace'] |
27 | 22 | for k, family in enumerate(families):
|
28 |
| - font = font0.copy() |
| 23 | + font = FontProperties() |
29 | 24 | font.set_family(family)
|
30 |
| - t = plt.figtext(0.1, yp[k], family, fontproperties=font, **alignment) |
| 25 | + fig.text(0.1, yp[k], family, fontproperties=font, **alignment) |
31 | 26 |
|
32 | 27 | # Show style options
|
33 |
| - |
34 | 28 | styles = ['normal', 'italic', 'oblique']
|
35 |
| - |
36 |
| -t = plt.figtext(0.3, 0.9, 'style', fontproperties=font1, **alignment) |
37 |
| - |
| 29 | +fig.text(0.3, 0.9, 'style', fontproperties=heading_font, **alignment) |
38 | 30 | for k, style in enumerate(styles):
|
39 |
| - font = font0.copy() |
| 31 | + font = FontProperties() |
40 | 32 | font.set_family('sans-serif')
|
41 | 33 | font.set_style(style)
|
42 |
| - t = plt.figtext(0.3, yp[k], style, fontproperties=font, **alignment) |
| 34 | + fig.text(0.3, yp[k], style, fontproperties=font, **alignment) |
43 | 35 |
|
44 | 36 | # Show variant options
|
45 |
| - |
46 | 37 | variants = ['normal', 'small-caps']
|
47 |
| - |
48 |
| -t = plt.figtext(0.5, 0.9, 'variant', fontproperties=font1, **alignment) |
49 |
| - |
| 38 | +fig.text(0.5, 0.9, 'variant', fontproperties=heading_font, **alignment) |
50 | 39 | for k, variant in enumerate(variants):
|
51 |
| - font = font0.copy() |
| 40 | + font = FontProperties() |
52 | 41 | font.set_family('serif')
|
53 | 42 | font.set_variant(variant)
|
54 |
| - t = plt.figtext(0.5, yp[k], variant, fontproperties=font, **alignment) |
| 43 | + fig.text(0.5, yp[k], variant, fontproperties=font, **alignment) |
55 | 44 |
|
56 | 45 | # Show weight options
|
57 |
| - |
58 | 46 | weights = ['light', 'normal', 'medium', 'semibold', 'bold', 'heavy', 'black']
|
59 |
| - |
60 |
| -t = plt.figtext(0.7, 0.9, 'weight', fontproperties=font1, **alignment) |
61 |
| - |
| 47 | +fig.text(0.7, 0.9, 'weight', fontproperties=heading_font, **alignment) |
62 | 48 | for k, weight in enumerate(weights):
|
63 |
| - font = font0.copy() |
| 49 | + font = FontProperties() |
64 | 50 | font.set_weight(weight)
|
65 |
| - t = plt.figtext(0.7, yp[k], weight, fontproperties=font, **alignment) |
| 51 | + fig.text(0.7, yp[k], weight, fontproperties=font, **alignment) |
66 | 52 |
|
67 | 53 | # Show size options
|
68 |
| - |
69 |
| -sizes = ['xx-small', 'x-small', 'small', 'medium', 'large', |
70 |
| - 'x-large', 'xx-large'] |
71 |
| - |
72 |
| -t = plt.figtext(0.9, 0.9, 'size', fontproperties=font1, **alignment) |
73 |
| - |
| 54 | +sizes = [ |
| 55 | + 'xx-small', 'x-small', 'small', 'medium', 'large', 'x-large', 'xx-large'] |
| 56 | +fig.text(0.9, 0.9, 'size', fontproperties=heading_font, **alignment) |
74 | 57 | for k, size in enumerate(sizes):
|
75 |
| - font = font0.copy() |
| 58 | + font = FontProperties() |
76 | 59 | font.set_size(size)
|
77 |
| - t = plt.figtext(0.9, yp[k], size, fontproperties=font, **alignment) |
| 60 | + fig.text(0.9, yp[k], size, fontproperties=font, **alignment) |
78 | 61 |
|
79 | 62 | # Show bold italic
|
80 |
| - |
81 |
| -font = font0.copy() |
82 |
| -font.set_style('italic') |
83 |
| -font.set_weight('bold') |
84 |
| -font.set_size('x-small') |
85 |
| -t = plt.figtext(0.3, 0.1, 'bold italic', fontproperties=font, **alignment) |
86 |
| - |
87 |
| -font = font0.copy() |
88 |
| -font.set_style('italic') |
89 |
| -font.set_weight('bold') |
90 |
| -font.set_size('medium') |
91 |
| -t = plt.figtext(0.3, 0.2, 'bold italic', fontproperties=font, **alignment) |
92 |
| - |
93 |
| -font = font0.copy() |
94 |
| -font.set_style('italic') |
95 |
| -font.set_weight('bold') |
96 |
| -font.set_size('x-large') |
97 |
| -t = plt.figtext(-0.4, 0.3, 'bold italic', fontproperties=font, **alignment) |
| 63 | +font = FontProperties(style='italic', weight='bold', size='x-small') |
| 64 | +fig.text(0.3, 0.1, 'bold italic', fontproperties=font, **alignment) |
| 65 | +font = FontProperties(style='italic', weight='bold', size='medium') |
| 66 | +fig.text(0.3, 0.2, 'bold italic', fontproperties=font, **alignment) |
| 67 | +font = FontProperties(style='italic', weight='bold', size='x-large') |
| 68 | +fig.text(0.3, 0.3, 'bold italic', fontproperties=font, **alignment) |
98 | 69 |
|
99 | 70 | plt.show()
|
0 commit comments