回答編集履歴
1
answer
CHANGED
@@ -7,19 +7,35 @@
|
|
7
7
|
X = [0, 1, 4, 9]
|
8
8
|
Y = [0, 3, 9, 8]
|
9
9
|
Z = [9, 4, 8, 3]
|
10
|
+
data = [X, Y, Z]
|
11
|
+
label = ['X', 'Y', 'Z']
|
12
|
+
l = len(data)
|
10
13
|
x = range(len(X))
|
11
14
|
|
12
15
|
fig = plt.figure()
|
13
|
-
gs = fig.add_gridspec(
|
16
|
+
gs = fig.add_gridspec(l, hspace=0)
|
14
|
-
axs = gs.subplots(sharex=True
|
17
|
+
axs = gs.subplots(sharex=True)
|
15
18
|
|
16
19
|
fig.suptitle('Multiple plots')
|
20
|
+
for i in range(l):
|
21
|
+
axs[i].scatter(x, data[i])
|
22
|
+
axs[i].set_xticks(x)
|
23
|
+
y1, y2 = axs[i].get_ylim()
|
24
|
+
print(y1, y2)
|
25
|
+
length = y2 - y1
|
17
|
-
axs[
|
26
|
+
axs[i].set_ylim((y1-length*2, y2+length*2))
|
18
|
-
axs[
|
27
|
+
axs[i].set_yticks([y1+(y2-y1)/2])
|
19
|
-
axs[
|
28
|
+
axs[i].set_yticklabels(label[i])
|
20
29
|
|
30
|
+
for ax in axs:
|
21
|
-
|
31
|
+
ax.label_outer()
|
32
|
+
ax.grid()
|
22
33
|
|
34
|
+
for ax in axs[:-1]:
|
35
|
+
ax.spines[['right', 'left', 'top', 'bottom']].set_visible(False)
|
36
|
+
|
37
|
+
axs[-1].spines[['right', 'left', 'top']].set_visible(False)
|
38
|
+
|
23
39
|
plt.show()
|
24
40
|
```
|
25
|
-

|