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

Skip to content

Commit 21a69ff

Browse files
committed
adjusted spacing for fonts demos
svn path=/trunk/matplotlib/; revision=365
1 parent 413a1be commit 21a69ff

3 files changed

Lines changed: 27 additions & 15 deletions

File tree

CHANGELOG

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
New entries should be added at the top
22
=======
33

4+
2004-06-25 Fixed fonts_demo spacing problems and added a kwargs
5+
version of the fonts_demo fonts_demo_kw.py - JDH
6+
47
2004-06-25 finance.py: handle case when urlopen() fails - SC
58

69
2004-06-24 Support for multiple images on axes and figure, with
@@ -34,7 +37,8 @@ New entries should be added at the top
3437

3538
2004-06-15 removed set_default_font from font_manager to unify font
3639
customization using the new function rc. See API_CHANGES
37-
fpr more info - JDH
40+
for more info. The examples fonts_demo.py and
41+
fonts_demo_kw.py are ported to the new API - JDH
3842

3943
2004-06-15 Improved (yet again!) axis scaling to properly handle
4044
singleton plots - JDH

examples/fonts_demo.py

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
#!/usr/bin/env python
2+
"""
3+
Show how to set custom font properties.
24
5+
For interactive users, you can also use kwargs to the text command,
6+
which requires less typing. See exampes/fonts_demo_kw.py
7+
"""
38
from matplotlib.font_manager import fontManager, FontProperties
49
from matplotlib.matlab import *
510

@@ -45,14 +50,14 @@
4550

4651
variant= ['normal', 'small-caps']
4752

48-
t = text(0.2, 0.9, 'variant', fontproperties=font1,
53+
t = text(0.0, 0.9, 'variant', fontproperties=font1,
4954
**alignment)
5055

5156
for k in range(1):
5257
font = font0.copy()
5358
font.set_family('serif')
5459
font.set_variant(variant[k])
55-
t = text( 0.2, yp[k], variant[k], fontproperties=font,
60+
t = text( 0.0, yp[k], variant[k], fontproperties=font,
5661
**alignment)
5762

5863
### Show weight options
@@ -83,26 +88,27 @@
8388
**alignment)
8489

8590
### Show bold italic
86-
left = 0.1
91+
8792
font = font0.copy()
8893
font.set_style('italic')
8994
font.set_weight('bold')
9095
font.set_size('x-small')
91-
t = text(left, 0.1, 'bold italic', fontproperties=font,
96+
t = text(0, 0.1, 'bold italic', fontproperties=font,
9297
**alignment)
9398

9499
font = font0.copy()
95100
font.set_style('italic')
96101
font.set_weight('bold')
97102
font.set_size('medium')
98-
t = text(left, 0.2, 'bold italic', fontproperties=font,
103+
t = text(0, 0.2, 'bold italic', fontproperties=font,
99104
**alignment)
100105

101106
font = font0.copy()
102107
font.set_style('italic')
103108
font.set_weight('bold')
104109
font.set_size('x-large')
105-
t = text(left, 0.3, 'bold italic', fontproperties=font,
110+
t = text(0, 0.3, 'bold italic', fontproperties=font,
106111
**alignment)
107112

113+
axis([-1,1,0,1])
108114
show()

examples/fonts_demo_kw.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
#!/usr/bin/env python
22
"""
3-
Same as fonts_demo using kwargs
3+
Same as fonts_demo using kwargs. If you prefer a more pythonic, OO
4+
style of coding, see examples/fonts_demo.py.
5+
46
"""
57
from matplotlib.font_manager import fontManager, FontProperties
68
from matplotlib.matlab import *
@@ -36,10 +38,10 @@
3638

3739
variant= ['normal', 'small-caps']
3840

39-
t = text(0.2, 0.9, 'variant', **alignment)
41+
t = text(0.0, 0.9, 'variant', **alignment)
4042

4143
for k in range(1):
42-
t = text( 0.2, yp[k], variant[k], family='serif', variant=variant[k],
44+
t = text( 0.0, yp[k], variant[k], family='serif', variant=variant[k],
4345
**alignment)
4446

4547
### Show weight options
@@ -63,19 +65,19 @@
6365
t = text( 0.8, yp[k], size[k], size=size[k],
6466
**alignment)
6567

66-
left = 0.1
68+
x = 0
6769
### Show bold italic
68-
t = text(left, 0.1, 'bold italic', style='italic',
70+
t = text(x, 0.1, 'bold italic', style='italic',
6971
weight='bold', size='x-small',
7072
**alignment)
7173

72-
t = text(left, 0.2, 'bold italic',
74+
t = text(x, 0.2, 'bold italic',
7375
style = 'italic', weight='bold', size='medium',
7476
**alignment)
7577

76-
t = text(left, 0.3, 'bold italic',
78+
t = text(x, 0.3, 'bold italic',
7779
style='italic', weight='bold', size='x-large',
7880
**alignment)
7981

80-
82+
axis([-1, 1, 0, 1])
8183
show()

0 commit comments

Comments
 (0)