質問編集履歴
1
質問の参照のためのコードを追加。
title
CHANGED
File without changes
|
body
CHANGED
@@ -3,4 +3,52 @@
|
|
3
3
|
|
4
4
|
個人的には、グラフを1つ作る場合は、plt.plotを使い、
|
5
5
|
2つ以上作る場合は、plt.sublot、add_subplot、subplotsとし、
|
6
|
-
さらに後者2つは、グラフを描く下地のサイズを任意に指定できると思っています。
|
6
|
+
さらに後者2つは、グラフを描く下地のサイズを任意に指定できると思っています。
|
7
|
+
|
8
|
+
|
9
|
+
【以下、参照として】
|
10
|
+
|
11
|
+
```python
|
12
|
+
import numpy as np
|
13
|
+
import matplotlib.pyplot as plt
|
14
|
+
|
15
|
+
x=np.arange(-1,1,0.01)
|
16
|
+
y=x**2
|
17
|
+
|
18
|
+
# plt.plot
|
19
|
+
plt.plot(x,y)
|
20
|
+
plt.show()
|
21
|
+
```
|
22
|
+

|
23
|
+
|
24
|
+
```python
|
25
|
+
#plt.subplot
|
26
|
+
plt.subplot(2,2,1)
|
27
|
+
plt.plot(x,y)
|
28
|
+
|
29
|
+
plt.subplot(2,2,4)
|
30
|
+
plt.plot(x,y)
|
31
|
+
plt.show()
|
32
|
+
```
|
33
|
+

|
34
|
+
|
35
|
+
```python
|
36
|
+
#add_subplot
|
37
|
+
fig = plt.figure(figsize=(8,6))
|
38
|
+
ax1=fig.add_subplot(221)
|
39
|
+
ax1.plot(x,y)
|
40
|
+
|
41
|
+
ax2=fig.add_subplot(224)
|
42
|
+
ax2.plot(x,y)
|
43
|
+
plt.show()
|
44
|
+
```
|
45
|
+

|
46
|
+
|
47
|
+
```python
|
48
|
+
#subplots
|
49
|
+
fig,ax = plt.subplots(2,2,figsize=(8,6))
|
50
|
+
ax[0,0].plot(x,y)
|
51
|
+
ax[1,1].plot(x,y)
|
52
|
+
plt.show()
|
53
|
+
```
|
54
|
+

|