Menu

[r319]: / trunk / htdocs / examples / font_properties_demo.py  Maximize  Restore  History

Download this file

22 lines (17 with data), 638 Bytes

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
#!/usr/bin/env python
from matplotlib.font_manager import set_default_font, get_default_font
from matplotlib.matlab import *
font = get_default_font()
font.set_family('serif') # this operates on the default font!
otherFont = font.copy() # this is an independent font
otherFont.set_family('monospace')
otherFont.set_weight('bold')
otherFont.set_size('larger')
plot(arange(20))
title('something')
set_default_font(otherFont)
for i in range(1,15,2):
text(i, i, 'label %d'%i, color='g') # uses otherFont
set_default_font(font) # restore default
xlabel('hi mom') # uses font
show()
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.