Movatterモバイル変換


[0]ホーム

URL:


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

Sign up
Appearance settings

Commitbf1bb92

Browse files
committed
mep12 on ganged_plots.py
1 parente62d9fa commitbf1bb92

File tree

1 file changed

+18
-18
lines changed

1 file changed

+18
-18
lines changed
Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
#!/usr/bin/env python
21
"""
32
To create plots that share a common axes (visually) you can set the
43
hspace between the subplots close to zero (do not use zero itself).
@@ -8,38 +7,39 @@
87
In this example the plots share a common xaxis but you can follow the
98
same logic to supply a common y axis.
109
"""
11-
frompylabimport*
10+
importmatplotlib.pyplotasplt
11+
importnumpyasnp
1212

13-
t=arange(0.0,2.0,0.01)
13+
t=np.arange(0.0,2.0,0.01)
1414

15-
s1=sin(2*pi*t)
16-
s2=exp(-t)
15+
s1=np.sin(2*np.pi*t)
16+
s2=np.exp(-t)
1717
s3=s1*s2
1818

1919
# axes rect in relative 0,1 coords left, bottom, width, height. Turn
2020
# off xtick labels on all but the lower plot
2121

2222

23-
f=figure()
24-
subplots_adjust(hspace=0.001)
23+
f=plt.figure()
24+
plt.subplots_adjust(hspace=0.001)
2525

2626

27-
ax1=subplot(311)
27+
ax1=plt.subplot(311)
2828
ax1.plot(t,s1)
29-
yticks(arange(-0.9,1.0,0.4))
30-
ylim(-1,1)
29+
plt.yticks(np.arange(-0.9,1.0,0.4))
30+
plt.ylim(-1,1)
3131

32-
ax2=subplot(312,sharex=ax1)
32+
ax2=plt.subplot(312,sharex=ax1)
3333
ax2.plot(t,s2)
34-
yticks(arange(0.1,1.0,0.2))
35-
ylim(0,1)
34+
plt.yticks(np.arange(0.1,1.0,0.2))
35+
plt.ylim(0,1)
3636

37-
ax3=subplot(313,sharex=ax1)
37+
ax3=plt.subplot(313,sharex=ax1)
3838
ax3.plot(t,s3)
39-
yticks(arange(-0.9,1.0,0.4))
40-
ylim(-1,1)
39+
plt.yticks(np.arange(-0.9,1.0,0.4))
40+
plt.ylim(-1,1)
4141

4242
xticklabels=ax1.get_xticklabels()+ax2.get_xticklabels()
43-
setp(xticklabels,visible=False)
43+
plt.setp(xticklabels,visible=False)
4444

45-
show()
45+
plt.show()

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp