|
1 |
| -#!/usr/bin/env python |
2 |
| - |
3 |
| -from pylab import * |
| 1 | +import matplotlib.pyplot as plt |
| 2 | +import numpy as np |
4 | 3 |
|
5 | 4 | # create some data to use for the plot
|
6 | 5 | dt = 0.001
|
7 |
| -t = arange(0.0, 10.0, dt) |
8 |
| -r = exp(-t[:1000]/0.05) # impulse response |
9 |
| -x = randn(len(t)) |
10 |
| -s = convolve(x, r)[:len(x)]*dt # colored noise |
| 6 | +t = np.arange(0.0, 10.0, dt) |
| 7 | +r = np.exp(-t[:1000]/0.05) # impulse response |
| 8 | +x = np.random.randn(len(t)) |
| 9 | +s = np.convolve(x, r)[:len(x)]*dt # colored noise |
11 | 10 |
|
12 | 11 | # the main axes is subplot(111) by default
|
13 |
| -plot(t, s) |
14 |
| -axis([0, 1, 1.1*amin(s), 2*amax(s)]) |
15 |
| -xlabel('time (s)') |
16 |
| -ylabel('current (nA)') |
17 |
| -title('Gaussian colored noise') |
| 12 | +plt.plot(t, s) |
| 13 | +plt.axis([0, 1, 1.1*np.amin(s), 2*np.amax(s)]) |
| 14 | +plt.xlabel('time (s)') |
| 15 | +plt.ylabel('current (nA)') |
| 16 | +plt.title('Gaussian colored noise') |
18 | 17 |
|
19 | 18 | # this is an inset axes over the main axes
|
20 |
| -a = axes([.65, .6, .2, .2], axisbg='y') |
21 |
| -n, bins, patches = hist(s, 400, normed=1) |
22 |
| -title('Probability') |
23 |
| -setp(a, xticks=[], yticks=[]) |
| 19 | +a = plt.axes([.65, .6, .2, .2], axisbg='y') |
| 20 | +n, bins, patches = plt.hist(s, 400, normed=1) |
| 21 | +plt.title('Probability') |
| 22 | +plt.xticks([]) |
| 23 | +plt.yticks([]) |
24 | 24 |
|
25 | 25 | # this is another inset axes over the main axes
|
26 |
| -a = axes([0.2, 0.6, .2, .2], axisbg='y') |
27 |
| -plot(t[:len(r)], r) |
28 |
| -title('Impulse response') |
29 |
| -setp(a, xlim=(0, .2), xticks=[], yticks=[]) |
30 |
| - |
| 26 | +a = plt.axes([0.2, 0.6, .2, .2], axisbg='y') |
| 27 | +plt.plot(t[:len(r)], r) |
| 28 | +plt.title('Impulse response') |
| 29 | +plt.xlim(0, 0.2) |
| 30 | +plt.xticks([]) |
| 31 | +plt.yticks([]) |
31 | 32 |
|
32 |
| -show() |
| 33 | +plt.show() |
0 commit comments