質問するログイン新規登録

回答編集履歴

1

figでないとだめ

2019/10/17 04:48

投稿

hayataka2049
hayataka2049

スコア30939

answer CHANGED
@@ -1,5 +1,9 @@
1
1
  プロットを行うタイミングでラベルを指定するのが一番やりやすいかと思います。
2
2
 
3
+ `Figure.legend`より存在するプロットすべてのラベルを凡例に反映できます。
4
+
5
+ [matplotlib.figure.Figure — Matplotlib 3.1.1 documentation](https://matplotlib.org/3.1.1/api/_as_gen/matplotlib.figure.Figure.html#matplotlib.figure.Figure.legend)
6
+
3
7
  ```python
4
8
  ax1.plot(hist1_acc_t, label="acc", color="red")
5
9
  ax1.plot(hist1_acc_v, label="val_acc", color="orange")
@@ -8,7 +12,7 @@
8
12
 
9
13
  # 中略
10
14
 
11
- plt.legend(ncol=2)
15
+ fig.legend(ncol=2)
12
16
 
13
17
 
14
18
  ```