Matplotlib 在plt.scatter中绘制空心圆

Matplotlib 在plt.scatter中绘制空心圆,matplotlib,scatter,Matplotlib,Scatter,我想通过使用两个索引[ChildrenHeight,ParentHeight]为分类变量[gender]绘制散点图。然而,我已经厌倦了许多方法来画一个带有明显边缘颜色的空圆圈 我试过: plt.scatter(X[:, 0], X[:, 1], c=y, marker = 'o',facecolors='none', cmap=plt.cm.Set1) 但它只是给了我一个完整的圆圈: 不要以这种方式使用cmap,请尝试fillstyle='none'命令: 比如说, x = np.random

我想通过使用两个索引[ChildrenHeight,ParentHeight]为分类变量[gender]绘制散点图。然而,我已经厌倦了许多方法来画一个带有明显边缘颜色的空圆圈

我试过:

plt.scatter(X[:, 0], X[:, 1], c=y, marker = 'o',facecolors='none', cmap=plt.cm.Set1)
但它只是给了我一个完整的圆圈:


不要以这种方式使用
cmap
,请尝试
fillstyle='none'
命令:

比如说,

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似乎不起作用。圆圈内的颜色仍然出现,因为y变量是0和1的分类值,我必须用不同的颜色绘制这两个变量,以取消
c=y
,并尝试使用
edgecolors=y
,其中
y
是不同的颜色。您可以在
if
条件下将它们存储在数组中,类似于
if y=1->color=red;else->color=gray