質問編集履歴
1
質問の参照のためのコードを追加。
test
CHANGED
File without changes
|
test
CHANGED
@@ -9,3 +9,99 @@
|
|
9
9
|
2つ以上作る場合は、plt.sublot、add_subplot、subplotsとし、
|
10
10
|
|
11
11
|
さらに後者2つは、グラフを描く下地のサイズを任意に指定できると思っています。
|
12
|
+
|
13
|
+
|
14
|
+
|
15
|
+
|
16
|
+
|
17
|
+
【以下、参照として】
|
18
|
+
|
19
|
+
|
20
|
+
|
21
|
+
```python
|
22
|
+
|
23
|
+
import numpy as np
|
24
|
+
|
25
|
+
import matplotlib.pyplot as plt
|
26
|
+
|
27
|
+
|
28
|
+
|
29
|
+
x=np.arange(-1,1,0.01)
|
30
|
+
|
31
|
+
y=x**2
|
32
|
+
|
33
|
+
|
34
|
+
|
35
|
+
# plt.plot
|
36
|
+
|
37
|
+
plt.plot(x,y)
|
38
|
+
|
39
|
+
plt.show()
|
40
|
+
|
41
|
+
```
|
42
|
+
|
43
|
+
![イメージ説明](69eb88770803da565d4b7f52759a87e2.png)
|
44
|
+
|
45
|
+
|
46
|
+
|
47
|
+
```python
|
48
|
+
|
49
|
+
#plt.subplot
|
50
|
+
|
51
|
+
plt.subplot(2,2,1)
|
52
|
+
|
53
|
+
plt.plot(x,y)
|
54
|
+
|
55
|
+
|
56
|
+
|
57
|
+
plt.subplot(2,2,4)
|
58
|
+
|
59
|
+
plt.plot(x,y)
|
60
|
+
|
61
|
+
plt.show()
|
62
|
+
|
63
|
+
```
|
64
|
+
|
65
|
+
![イメージ説明](f857725fdcbaa53e88caaa41d5c6d7ce.png)
|
66
|
+
|
67
|
+
|
68
|
+
|
69
|
+
```python
|
70
|
+
|
71
|
+
#add_subplot
|
72
|
+
|
73
|
+
fig = plt.figure(figsize=(8,6))
|
74
|
+
|
75
|
+
ax1=fig.add_subplot(221)
|
76
|
+
|
77
|
+
ax1.plot(x,y)
|
78
|
+
|
79
|
+
|
80
|
+
|
81
|
+
ax2=fig.add_subplot(224)
|
82
|
+
|
83
|
+
ax2.plot(x,y)
|
84
|
+
|
85
|
+
plt.show()
|
86
|
+
|
87
|
+
```
|
88
|
+
|
89
|
+
![イメージ説明](5c442c40e9899034414db417ad0b5a35.png)
|
90
|
+
|
91
|
+
|
92
|
+
|
93
|
+
```python
|
94
|
+
|
95
|
+
#subplots
|
96
|
+
|
97
|
+
fig,ax = plt.subplots(2,2,figsize=(8,6))
|
98
|
+
|
99
|
+
ax[0,0].plot(x,y)
|
100
|
+
|
101
|
+
ax[1,1].plot(x,y)
|
102
|
+
|
103
|
+
plt.show()
|
104
|
+
|
105
|
+
```
|
106
|
+
|
107
|
+
![イメージ説明](92f78007f899305e2cdbe314896bdc59.png)
|