Menu

[r148]: / trunk / htdocs / examples / text_handles.py  Maximize  Restore  History

Download this file

47 lines (35 with data), 1.1 kB

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#Controlling the properties of axis text using handles
# See axis_text_themes.py for a more elegant, pythonic way to control
# fonts. After all, if we were slaves to matlab , we wouldn't be
# using python!
from matplotlib.matlab import *
def f(t):
s1 = sin(2*pi*t)
e1 = exp(-t)
return multiply(s1,e1)
t1 = arange(0.0, 5.0, 0.1)
t2 = arange(0.0, 5.0, 0.02)
subplot(111)
plot(t1, f(t1), 'bo', t2, f(t2), 'k')
text(3.0, 0.6, 'f(t) = exp(-t) sin(2 pi t)')
ttext = title('Fun with text!')
ytext = ylabel('Damped oscillation')
xtext = xlabel('time (s)')
set(ttext, 'fontsize', 14)
set(ttext, 'color', 'r')
set(ttext, 'fontangle', 'italic')
set(xtext, 'fontsize', 12)
set(xtext, 'fontname', 'courier')
set(xtext, 'fontweight', 'bold')
set(xtext, 'color', 'g')
set(ytext, 'fontsize', 12)
set(ytext, 'fontname', 'helvetica')
set(ytext, 'fontweight', 'light')
set(ytext, 'color', 'b')
# TODO: fix me
#xticklabels = get(gca(), 'xticklabels')
#yticklabels = get(gca(), 'yticklabels')
#set(xticklabels, 'fontweight', 'bold')
#set(yticklabels, 'fontangle', 'italic')
savefig('text_handles')
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.