如何把上述散点图中df['WL']=1的点标为红色

动态 未结 0 155
小小草
小小草 LV1 2023年9月23日 23:40 发表
可以使用seaborn库中的scatterplot函数,通过hue参数指定颜色分类变量。具体代码如下: ``` import seaborn as sns import matplotlib.pyplot as plt # 绘制散点图,并按照WL列进行着色 sns.scatterplot(x=df.index, y=df['unique_wordcount'], hue=df['WL'], palette=['blue', 'red']) # 设置x轴标签和图表标题 plt.xlabel('Sample Collection of Winning Cases') plt.title('Scattered Distribution of Unique Word Count') # 显示图表 plt.show() ``` 其中,hue参数指定了颜色分类变量为df['WL'],palette参数指定了两种颜色的顺序,即蓝色和红色。这样,df['WL']=0的点会被标为蓝色,df['WL']=1的点会被标为红色。
收藏(0)  分享
相关标签: 智能问答
问题没解决?让AI助手帮你作答 AI助手
0个回复
  • 消灭零回复