我有两列数据,如下所示:
data = {'labels': {0: '00',
1: '08',
2: '00',
3: '08',
4: '5',
5: '04',
6: '08',
7: '04',
8: '08',
9: '5',
10: '5',
11: '04',
12: '5',
13: '00',
14: '08',
15: '5',
16: '00',
17: '00',
18: '04',
19: '04'},
'scores': {0: 0.0023585677121699122,
1: 0.056371229170055104,
2: 0.005376756883710199,
3: 0.05694460526172507,
4: 0.1049131006122696,
5: 0.008102266910447686,
6: 0.09154342979296892,
7: -0.03761723194472211,
8: 0.010718527281161072,
9: 0.11988838522095685,
10: 0.09070139731152083,
11: 0.02994813107318378,
12: 0.09277903598030868,
13: 0.062223925985664286,
14: 0.1377963110579728,
15: 0.11898618005936024,
16: -0.021227109409528988,
17: 0.008938944493717238,
18: 0.03413068403999525,
19: 0.058688416622356965}}
df = pd.DataFrame(data)
我想我试图绘制的值在scores
和颜色,它根据labels
。我已经尝试sns.scatterplot(data=df,x='labels',y='scores');
这可以工作,但它不显示集群(每个x值是分开的),如这里所示
我希望这些点在同一个空间,并根据df['labels']
的不同颜色。
1条答案
按热度按时间mfpqipee1#
sns.scatterplot(data=df,x='labels',y='scores', hue='labels')