質問編集履歴

2

誤字修正

2022/09/07 05:09

投稿

i113
i113

スコア74

test CHANGED
File without changes
test CHANGED
@@ -37,10 +37,10 @@
37
37
  x=["a","b","c","d","e","f"]
38
38
  y=[1,2,3,4,5,6]
39
39
  h=[0,0,0,0,0,0]
40
- s=[10,50,10,10,50,50]
40
+ s=[10,20,10,10,20,20]
41
41
  sizes = {x: x for x in s}
42
42
  colp = {-1:'#1F3FDF', 0:'#222222', +1:'#DF1F3F'}
43
- ax=sns.scatterplot(x=x, y=y, hue=h, s=s, sizes=sizes, palette=colp, legend="full")
43
+ ax=sns.scatterplot(x=x, y=y, hue=h, size=s, sizes=sizes, palette=colp, legend="full")
44
44
  handles, labels = ax.get_legend_handles_labels()
45
45
  ax.legend(handles=handles, labels=["-","/","+","0","1","2"], ncol=2, title="H_Type S_Type")
46
46
  ```

1

新たな問題を追加

2022/09/07 04:52

投稿

i113
i113

スコア74

test CHANGED
File without changes
test CHANGED
@@ -27,3 +27,21 @@
27
27
  ![イメージ説明](https://ddjkaamml8q8x.cloudfront.net/questions/2022-09-06/a38d15e4-dd26-4a60-bc67-31e728f25f62.png)
28
28
  凡例の - と 0 のマーカーが + と 2 のマーカーと同じものになっています。
29
29
  どうすれば修正できますか?
30
+
31
+ ※新たなる問題。
32
+ ※s や h の値によって失敗する例。
33
+ ```python
34
+ import seaborn as sns
35
+ import matplotlib.pylab as plt
36
+
37
+ x=["a","b","c","d","e","f"]
38
+ y=[1,2,3,4,5,6]
39
+ h=[0,0,0,0,0,0]
40
+ s=[10,50,10,10,50,50]
41
+ sizes = {x: x for x in s}
42
+ colp = {-1:'#1F3FDF', 0:'#222222', +1:'#DF1F3F'}
43
+ ax=sns.scatterplot(x=x, y=y, hue=h, s=s, sizes=sizes, palette=colp, legend="full")
44
+ handles, labels = ax.get_legend_handles_labels()
45
+ ax.legend(handles=handles, labels=["-","/","+","0","1","2"], ncol=2, title="H_Type S_Type")
46
+ ```
47
+ ![イメージ説明](https://ddjkaamml8q8x.cloudfront.net/questions/2022-09-07/e6817d77-ca70-421d-9e8f-36f3409a0b67.png)