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

Skip to content

Commit 76655e2

Browse files
committed
Merge pull request #4861 from ericmjl/multiple_figs_demo.py_mep12
mep12 on multiple_figs_demo.py
2 parents d37df04 + bd35517 commit 76655e2

File tree

1 file changed

+18
-22
lines changed

1 file changed

+18
-22
lines changed
Lines changed: 18 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,25 @@
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')
28-
29-
show()
25+
plt.show()

0 commit comments

Comments
 (0)