Menu

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

Download this file

34 lines (27 with data), 867 Bytes

 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
#!/usr/bin/env python
from matplotlib.matlab import *
# create some data to use for the plot
dt = 0.001
t = arange(0.0, 10.0, dt)
r = exp(-t[:1000]/0.05) # impulse response
x = randn(len(t))
s = convolve(x,r,mode=2)[:len(x)]*dt # colored noise
# the main axes is subplot(111) by default
plot(t, s)
axis([0, 1, 1.1*min(s), 2*max(s) ])
xlabel('time (s)')
ylabel('current (nA)')
title('Gaussian colored noise')
# this is an inset axes over the main axes
a = axes([.65, .6, .2, .2], axisbg='y')
n, bins, patches = hist(s, 400, normed=1)
title('Probability')
set(a, xticks=[], yticks=[])
# this is another inset axes over the main axes
a = axes([0.2, 0.6, .2, .2], axisbg='y')
plot(t[:len(r)], r)
title('Impulse response')
set(a, xlim=(0,.2), xticks=[], yticks=[])
#savefig('../figures/axes_demo.eps')
#savefig('../figures/axes_demo.png')
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.