回答編集履歴

2

Update

2022/07/10 05:04

投稿

melian
melian

スコア19825

test CHANGED
@@ -25,6 +25,13 @@
25
25
  plt.title("データの確認・可視化")
26
26
  plt.xlabel('vegetable')
27
27
  plt.ylabel('salt')
28
+
29
+ legend = [
30
+ plt.plot([], [], marker='o', ls='', color=colors[i], label=l)[0]
31
+ for i, l in enumerate(['worst', 'bad', 'good', 'best'], start=1)]
32
+ plt.legend(handles=legend, title='Score', loc='upper left', bbox_to_anchor=(1,1))
33
+
34
+ plt.tight_layout()
28
35
  plt.show()
29
36
  ```
30
- ![イメージ説明](https://ddjkaamml8q8x.cloudfront.net/questions/2022-07-10/6fbad1ae-fc21-4abc-b4b8-31820943e85f.png)
37
+ ![イメージ説明](https://ddjkaamml8q8x.cloudfront.net/questions/2022-07-10/063de2b7-46cb-441b-aa71-026196b2a255.png)

1

Update

2022/07/10 04:04

投稿

melian
melian

スコア19825

test CHANGED
@@ -22,14 +22,9 @@
22
22
  colors = {1:'green', 2:'yellow', 3:'blue', 4:'red'}
23
23
  df.plot.scatter(x='Vegetables[g]', y='Salt[g]', c=df['Score'].map(colors))
24
24
 
25
- xmax, ymax = df['Vegetables[g]'].max(), df['Salt[g]'].max()
26
- plt.xlim(-xmax*0.1, xmax*1.2)
27
- plt.ylim(-ymax*0.1, ymax*1.2)
28
-
29
25
  plt.title("データの確認・可視化")
30
26
  plt.xlabel('vegetable')
31
27
  plt.ylabel('salt')
32
28
  plt.show()
33
29
  ```
34
-
35
- ![イメージ説明](https://ddjkaamml8q8x.cloudfront.net/questions/2022-07-10/839b5f14-155f-4d01-b487-f5e0e334231b.png)
30
+ ![イメージ説明](https://ddjkaamml8q8x.cloudfront.net/questions/2022-07-10/6fbad1ae-fc21-4abc-b4b8-31820943e85f.png)