Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 9424a09

Browse files
committed
Merge pull request #4830 from ericmjl/mep12_axes_demo.py
mep12 on axes_demo.py
2 parents 86528e7 + 237d439 commit 9424a09

File tree

1 file changed

+23
-22
lines changed

1 file changed

+23
-22
lines changed

examples/pylab_examples/axes_demo.py

Lines changed: 23 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,33 @@
1-
#!/usr/bin/env python
2-
3-
from pylab import *
1+
import matplotlib.pyplot as plt
2+
import numpy as np
43

54
# create some data to use for the plot
65
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
1110

1211
# 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')
1817

1918
# 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([])
2424

2525
# 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([])
3132

32-
show()
33+
plt.show()

0 commit comments

Comments
 (0)