python - 如何有条件地更改散点图点形状?
问题描述
我的代码是这样的;
m = np.where(data['Education']== 'Undergraduate','*','o')
colors = np.where(data["Education"]== "Undergraduate",'r','b')
data.plot.scatter(x="Weight",y="Height",c=colors, marker=m)
plt.show()
它适用于颜色,但不适用于标记。请帮忙!!
解决方案
以下几行内容..是我的建议。
plt.scatter(x=data.Weight[data['Education'] == 'Graduate'],y=data.Height[data['Education'] == 'Graduate'],c='r', marker='*')
plt.scatter(x=data.Weight[data['Education'] == 'Undergraduate'],y=data.Height[data['Education'] == 'Undergraduate'],c='b', marker='o')
plt.show()
推荐阅读
- swift - Swift:测试使用委托调用的 URLSession
- json - 递归结构的 Json 模式不起作用
- python - 使用 flow_from_directory 时出现荒谬的损失和度量值
- javascript - 如何在 Vue.js 中 v-for 循环嵌套导航?
- c# - MD5 中的数据类型转换,无论是 SSIS 还是 C#
- selenium - 在使用 selenium(geckodriver)打开的浏览器上运行美丽的汤
- python-3.x - 如何在 python 中合并多个 xls 工作表?
- java - 防止 JavaMail 解码作为 java.lang.String 对象传递的 base-64 内容
- php - 在哪里托管 Braintree 进行生产?
- php - Laravel 中的正则表达式