Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit fed0454

Browse filesBrowse files
committed
mep12 on multiple_figs_demo.py
1 parent 1383295 commit fed0454
Copy full SHA for fed0454

File tree

Expand file treeCollapse file tree

1 file changed

+22
-21
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+22
-21
lines changed
+22-21Lines 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 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.