gpt4 book ai didi

Python matplotlib scatter - 一个散布中的不同标记

转载 作者:行者123 更新时间:2023-12-01 07:04:07 27 4
gpt4 key购买 nike

我想显示一些点。这是我的代码:

plt.scatter(y[:,0],y[:,1],c=col)
plt.show()

并作为 col我有:
Col:  [1 1 0 1 1 1 1 0 0 0 1 0 0 0 0 0 0 1 1 1 0 0 1 1 0 0 0 0 1 1 0 1 1 0 0 0 0
0 0 0 0 0 0 0 1 1 0 1 1 0 1 0 0 1 0 1 1 0 1 0 1 0 0 1 1 1 1 1 1 1 1 1 0 0
1 1 0 0 0 0 0 0 0 0 0 0 1 1 0 0 1 0 1 0 0 1 1 0 1 0 0]

所以我有两种不同颜色的点。但我也想要两个不同的标记。我该怎么做? markers=col给出一个错误。

最佳答案

Matplotlib 不支持在一次 scatter 调用中使用不同的标记。您必须使用两个不同的调用 scatter ;例如:

plt.scatter(y[col == 0, 0], y[col == 0, 1], marker='o')
plt.scatter(y[col == 1, 0], y[col == 1, 1], marker='+')

关于Python matplotlib scatter - 一个散布中的不同标记,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43528300/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com