回答編集履歴

2

補足を追加

2018/07/24 07:13

投稿

magichan
magichan

スコア15898

test CHANGED
@@ -33,3 +33,27 @@
33
33
  plt.show()
34
34
 
35
35
  ```
36
+
37
+
38
+
39
+ ---
40
+
41
+ **【更に】**
42
+
43
+
44
+
45
+ 特に色を指定しないなら
46
+
47
+
48
+
49
+ ```Python
50
+
51
+ for f in df['fruit'].unique():
52
+
53
+ plt.scatter(df.loc[df.fruit == f ,'no'], df.loc[df.fruit == f ,'値段'], label=f)
54
+
55
+ plt.legend()
56
+
57
+ plt.show()
58
+
59
+ ```

1

補足を追加

2018/07/24 07:12

投稿

magichan
magichan

スコア15898

test CHANGED
@@ -9,3 +9,27 @@
9
9
  plt.scatter(df['no'], df['price'], c=df['fruit'].cat.codes)
10
10
 
11
11
  ```
12
+
13
+
14
+
15
+ ---
16
+
17
+ **【補足】**
18
+
19
+ 色指定&凡例を出す場合
20
+
21
+
22
+
23
+ ```Python
24
+
25
+ colors = {'orange':'orange','apple':'red','peach':'pink'}
26
+
27
+ for f in df['fruit'].unique():
28
+
29
+ plt.scatter(df.loc[df.fruit == f ,'no'], df.loc[df.fruit == f ,'値段'], c=colors[f], label=f)
30
+
31
+ plt.legend()
32
+
33
+ plt.show()
34
+
35
+ ```