fillstyle = 'none'
命令:https://matplotlib.org/gallery/lines_bars_and_markers/marker_fillstyle_reference.html。x = np.random.randint(100, size=100)
y = np.random.randint(100, size=100)
plt.plot(x,y,lw=0, marker='o', fillstyle='none')
plt.show()
或者,如果你想使用plt.scatter
:
plt.scatter(x,y,marker='o', facecolors='none', edgecolors='r')
plt.show()
plt.scatter(X[:, 0], X[:, 1], c=y,marker='o', facecolors='none', edgecolors='r')
时,似乎 facecolors 不起作用。圆圈内部的颜色仍然出现。 - Qingc=y
并使用edgecolors=y
,其中y
为不同的颜色。 您可以将它们存储在一个数组中,在if
条件下进行处理,例如if y=1 -> color = red; else -> color=gray
。 - Alessandro Peca