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

Skip to content

Commit 99d105c

Browse files
committed
added font props demo
svn path=/trunk/matplotlib/; revision=235
1 parent 876c152 commit 99d105c

1 file changed

Lines changed: 20 additions & 0 deletions

File tree

examples/font_properties_demo.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
from matplotlib.font_manager import set_default_font, get_default_font
2+
from matplotlib.matlab import *
3+
4+
font = get_default_font()
5+
font.set_family('serif') # this operates on the default font!
6+
7+
otherFont = font.copy() # this is an independent font
8+
otherFont.set_family('monospace')
9+
otherFont.set_weight('bold')
10+
otherFont.set_size('larger')
11+
12+
plot(arange(20))
13+
title('something')
14+
15+
set_default_font(otherFont)
16+
for i in range(1,15,2):
17+
text(i, i, 'label %d'%i, color='g') # uses otherFont
18+
set_default_font(font) # restore default
19+
xlabel('hi mom') # uses font
20+
show()

0 commit comments

Comments
 (0)