回答編集履歴
4
修正
answer
CHANGED
@@ -38,8 +38,14 @@
|
|
38
38
|
seaborn.scatterplot() を使うと簡単です。
|
39
39
|
seaborn は `pip install seaborn` でインストールできます。
|
40
40
|
|
41
|
+
使い方
|
42
|
+
```python
|
43
|
+
seaborn.scatterplot(x="X座標の列名", y="Y座標の列名", hue="凡例の列名", data=DataFrame の変数, ax=ax)
|
44
|
+
```
|
45
|
+
|
41
46
|
[seaborn.scatterplot — seaborn 0.10.1 documentation](https://seaborn.pydata.org/generated/seaborn.scatterplot.html)
|
42
47
|
|
48
|
+
↓ サンプルコード
|
43
49
|
```python
|
44
50
|
import matplotlib.pyplot as plt
|
45
51
|
import pandas as pd
|
3
d
answer
CHANGED
@@ -36,6 +36,7 @@
|
|
36
36
|
## 追記
|
37
37
|
|
38
38
|
seaborn.scatterplot() を使うと簡単です。
|
39
|
+
seaborn は `pip install seaborn` でインストールできます。
|
39
40
|
|
40
41
|
[seaborn.scatterplot — seaborn 0.10.1 documentation](https://seaborn.pydata.org/generated/seaborn.scatterplot.html)
|
41
42
|
|
2
d
answer
CHANGED
@@ -31,4 +31,31 @@
|
|
31
31
|
plt.show()
|
32
32
|
```
|
33
33
|
|
34
|
-

|
34
|
+

|
35
|
+
|
36
|
+
## 追記
|
37
|
+
|
38
|
+
seaborn.scatterplot() を使うと簡単です。
|
39
|
+
|
40
|
+
[seaborn.scatterplot — seaborn 0.10.1 documentation](https://seaborn.pydata.org/generated/seaborn.scatterplot.html)
|
41
|
+
|
42
|
+
```python
|
43
|
+
import matplotlib.pyplot as plt
|
44
|
+
import pandas as pd
|
45
|
+
import seaborn as sns
|
46
|
+
|
47
|
+
df = pd.read_csv("sample.csv")
|
48
|
+
|
49
|
+
fig, ax = plt.subplots()
|
50
|
+
ax.set_xlim(4, 10) # x軸の表示範囲
|
51
|
+
ax.set_ylim(8, 14) # y軸の表示範囲
|
52
|
+
ax.set_title("Graph", fontsize=10) # タイトル
|
53
|
+
ax.set_xlabel("X axis", fontsize=10) # x軸ラベル
|
54
|
+
ax.set_ylabel("Y axis", fontsize=10) # y軸ラベル
|
55
|
+
ax.grid() # 目盛線の表示
|
56
|
+
ax.tick_params(labelsize=10) # 目盛線のラベルサイズ
|
57
|
+
|
58
|
+
sns.scatterplot(x="A", y="B", hue="C", data=df, ax=ax)
|
59
|
+
|
60
|
+
plt.show()
|
61
|
+
```
|
1
修正
answer
CHANGED
@@ -3,4 +3,32 @@
|
|
3
3
|
以下の手順で日本語フォントを設定すれば、反映されます。
|
4
4
|
(Jupyter Notebook の場合、Notebook を再起動してください)
|
5
5
|
|
6
|
-
[matplotlib - コピペするだけで matplotlib を日本語化する方法 (Windows / Ubuntu 対応) - pystyle](https://pystyle.info/japanize-matplotlib-just-by-copying-and-pasting/)
|
6
|
+
[matplotlib - コピペするだけで matplotlib を日本語化する方法 (Windows / Ubuntu 対応) - pystyle](https://pystyle.info/japanize-matplotlib-just-by-copying-and-pasting/)
|
7
|
+
|
8
|
+
## 追記
|
9
|
+
|
10
|
+
点ごとに凡例を用意するということでしょうか?
|
11
|
+
|
12
|
+
```python
|
13
|
+
import matplotlib.pyplot as plt
|
14
|
+
import pandas as pd
|
15
|
+
|
16
|
+
df = pd.read_csv("sample.csv")
|
17
|
+
|
18
|
+
plt.xlim(4, 10) # x軸の表示範囲
|
19
|
+
plt.ylim(8, 14) # y軸の表示範囲
|
20
|
+
plt.title("Graph", fontsize=10) # タイトル
|
21
|
+
plt.xlabel("X axis", fontsize=10) # x軸ラベル
|
22
|
+
plt.ylabel("Y axis", fontsize=10) # y軸ラベル
|
23
|
+
plt.grid(True) # 目盛線の表示
|
24
|
+
plt.tick_params(labelsize=10) # 目盛線のラベルサイズ
|
25
|
+
|
26
|
+
# グラフの描画
|
27
|
+
for row in df.itertuples():
|
28
|
+
plt.scatter(row.A, row.B, s=50, marker="D", alpha=0.7, label=row.C)
|
29
|
+
|
30
|
+
plt.legend(loc="lower right", fontsize=10)
|
31
|
+
plt.show()
|
32
|
+
```
|
33
|
+
|
34
|
+

|