Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Plot hollow circles in plt.scatter [duplicate]

I would like to plot a scatter plot by using 2 indexes [ChildrenHeight, ParentHeight] for a categorical variable: [gender]. However, I have tired many approaches to draw a empty circle with distinct edgecolors.

I have tried:

plt.scatter(X[:, 0], X[:, 1], c=y, marker = 'o',facecolors='none', cmap=plt.cm.Set1)

but it just gave me full circles:

enter image description here

like image 586
Qing Avatar asked Oct 16 '22 20:10

Qing


1 Answers

Don't use cmap in that way, try fillstyle = 'none' command : https://matplotlib.org/gallery/lines_bars_and_markers/marker_fillstyle_reference.html

For example,

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()

enter image description here

Or, if you want tu use plt.scatter:

plt.scatter(x,y,marker='o', facecolors='none', edgecolors='r')

plt.show()

enter image description here

like image 185
Alessandro Peca Avatar answered Oct 21 '22 00:10

Alessandro Peca