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

Skip to content

Commit fed0454

Browse files
committed
mep12 on multiple_figs_demo.py
1 parent 1383295 commit fed0454

File tree

1 file changed

+22
-21
lines changed

1 file changed

+22
-21
lines changed
Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,30 @@
1-
#!/usr/bin/env python
21
# Working with multiple figure windows and subplots
3-
from pylab import *
2+
import matplotlib.pyplot as plt
3+
import numpy as np
44

5-
t = arange(0.0, 2.0, 0.01)
6-
s1 = sin(2*pi*t)
7-
s2 = sin(4*pi*t)
5+
t = np.arange(0.0, 2.0, 0.01)
6+
s1 = np.sin(2*np.pi*t)
7+
s2 = np.sin(4*np.pi*t)
88

9-
figure(1)
10-
subplot(211)
11-
plot(t, s1)
12-
subplot(212)
13-
plot(t, 2*s1)
9+
plt.figure(1)
10+
plt.subplot(211)
11+
plt.plot(t, s1)
12+
plt.subplot(212)
13+
plt.plot(t, 2*s1)
1414

15-
figure(2)
16-
plot(t, s2)
15+
plt.figure(2)
16+
plt.plot(t, s2)
1717

1818
# now switch back to figure 1 and make some changes
19-
figure(1)
20-
subplot(211)
21-
plot(t, s2, 'gs')
22-
setp(gca(), 'xticklabels', [])
19+
plt.figure(1)
20+
plt.subplot(211)
21+
plt.plot(t, s2, 'gs')
22+
ax = plt.gca()
23+
ax.set_xticklabels([])
2324

24-
figure(1)
25-
savefig('fig1')
26-
figure(2)
27-
savefig('fig2')
25+
plt.figure(1)
26+
plt.savefig('fig1')
27+
plt.figure(2)
28+
plt.savefig('fig2')
2829

29-
show()
30+
plt.show()

0 commit comments

Comments
 (0)