我在做一个散点图,根据数据中的条件使用两个不同的符号。 在遍历数据行的for循环中,如果满足条件,则用圆绘制点,如果不满足条件,则用正方形绘制点:
for i in thick.index:
if thick['Interest'][i] == 1:
plt.scatter(thick['NiThickness'][i], thick['GdThickness'][i], marker = 'o', color = 'b')
else:
plt.scatter(thick['NiThickness'][i], thick['GdThickness'][i], marker = 's', color = 'r')
其中“Interest”是一个填充了1和0(零?)的列。你知道吗
我希望在图例中有一个圆形标签,一个正方形标签,但是如果我在plt.scatter(...)
命令中声明label = 'circle'
,那么图例中的行数与数据文件中的行数相同。你知道吗
有没有一个简单的小把戏我错过了?你知道吗
谢谢。你知道吗
如果
thick
是数据帧:这是我在这种情况下使用的模式:
这也很好地解决了只有一个类别存在的情况。你知道吗
相关问题 更多 >
编程相关推荐