Menu

[r540]: / trunk / htdocs / examples / axes_props.py  Maximize  Restore  History

Download this file

66 lines (50 with data), 1.4 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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#!/usr/bin/env python
"""
You can control the axis tick and grid properties
"""
from matplotlib.matlab import *
t = arange(0.0, 2.0, 0.01)
s = sin(2*pi*t)
plot(t, s)
grid(True)
# matlab handle graphics style
xticklines = get(gca(), 'xticklines')
yticklines = get(gca(), 'yticklines')
xgridlines = get(gca(), 'xgridlines')
ygridlines = get(gca(), 'ygridlines')
xticklabels = get(gca(), 'xticklabels')
yticklabels = get(gca(), 'yticklabels')
set(xticklines, 'linewidth', 3)
set(yticklines, 'linewidth', 3)
set(xgridlines, 'linestyle', '-')
set(ygridlines, 'linestyle', '-')
set(yticklabels, 'color', 'r', fontsize='medium')
set(xticklabels, 'color', 'r', fontsize='medium')
# keyword args are legal too
#set(xticklabels, color='r', fontsize='medium')
#savefig('axprops_demo')
show()
"""
# the same script, python style
from matplotlib.matlab import *
t = arange(0.0, 2.0, 0.01)
s = sin(2*pi*t)
ax = subplot(111)
ax.plot(t, s)
ax.grid(True)
ticklines = ax.get_xticklines()
ticklines.extend( ax.get_yticklines() )
gridlines = ax.get_xgridlines()
gridlines.extend( ax.get_ygridlines() )
ticklabels = ax.get_xticklabels()
ticklabels.extend( ax.get_yticklabels() )
for line in ticklines:
line.set_linewidth(3)
for line in gridlines:
line.set_linestyle('-')
for label in ticklabels:
label.set_color('r')
label.set_fontsize('medium')
#savefig('axprops_demo')
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.