Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit c48f88d

Browse files
committed
Improve fonts_demo_kw
1 parent 38fbda6 commit c48f88d

File tree

1 file changed

+18
-22
lines changed

1 file changed

+18
-22
lines changed

examples/pylab_examples/fonts_demo_kw.py

Lines changed: 18 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -12,61 +12,57 @@
1212

1313
# Show family options
1414

15-
family = ['serif', 'sans-serif', 'cursive', 'fantasy', 'monospace']
15+
families = ['serif', 'sans-serif', 'cursive', 'fantasy', 'monospace']
1616

1717
t = text(-0.8, 0.9, 'family', size='large', **alignment)
1818

19-
yp = [0.7, 0.5, 0.3, 0.1, -0.1, -0.3, -0.5]
19+
yp = [0.8, 0.7, 0.6, 0.5, 0.4, 0.3, 0.2]
2020

21-
for k in range(5):
22-
if k == 2:
23-
t = text(-0.8, yp[k], family[k], family=family[k],
24-
name='Script MT', **alignment)
25-
else:
26-
t = text(-0.8, yp[k], family[k], family=family[k], **alignment)
21+
for k, family in enumerate(families):
22+
t = text(-0.8, yp[k], family, family=family, **alignment)
2723

2824
# Show style options
2925

30-
style = ['normal', 'italic', 'oblique']
26+
styles = ['normal', 'italic', 'oblique']
3127

3228
t = text(-0.4, 0.9, 'style', **alignment)
3329

34-
for k in range(3):
35-
t = text(-0.4, yp[k], style[k], family='sans-serif', style=style[k],
30+
for k, style in enumerate(styles):
31+
t = text(-0.4, yp[k], style, family='sans-serif', style=style,
3632
**alignment)
3733

3834
# Show variant options
3935

40-
variant = ['normal', 'small-caps']
36+
variants = ['normal', 'small-caps']
4137

4238
t = text(0.0, 0.9, 'variant', **alignment)
4339

44-
for k in range(2):
45-
t = text(0.0, yp[k], variant[k], family='serif', variant=variant[k],
40+
for k, variant in enumerate(variants):
41+
t = text(0.0, yp[k], variant, family='serif', variant=variant,
4642
**alignment)
4743

4844
# Show weight options
4945

50-
weight = ['light', 'normal', 'medium', 'semibold', 'bold', 'heavy', 'black']
46+
weights = ['light', 'normal', 'medium', 'semibold', 'bold', 'heavy', 'black']
5147

5248
t = text(0.4, 0.9, 'weight', **alignment)
5349

54-
for k in range(7):
55-
t = text(0.4, yp[k], weight[k], weight=weight[k],
50+
for k, weight in enumerate(weights):
51+
t = text(0.4, yp[k], weight, weight=weight,
5652
**alignment)
5753

5854
# Show size options
5955

60-
size = ['xx-small', 'x-small', 'small', 'medium', 'large',
61-
'x-large', 'xx-large']
56+
sizes = ['xx-small', 'x-small', 'small', 'medium', 'large',
57+
'x-large', 'xx-large']
6258

6359
t = text(0.8, 0.9, 'size', **alignment)
6460

65-
for k in range(7):
66-
t = text(0.8, yp[k], size[k], size=size[k],
61+
for k, size in enumerate(sizes):
62+
t = text(0.8, yp[k], size, size=size,
6763
**alignment)
6864

69-
x = 0
65+
x = -0.4
7066
# Show bold italic
7167
t = text(x, 0.1, 'bold italic', style='italic',
7268
weight='bold', size='x-small',

0 commit comments

Comments
 (0)