Reputation: 2158
I have a matrix X
of shape Nx2
and a corresponding set of labels (5 labels for 5 classes, eg., 0,1,2,3,4) in matrix Y
of length N
. Now I want to plot X
using matplotlib scatter plot such that the value in X
corresponding to each label in Y
comes in a different colour. I'm not sure about the exact parameters of plt.scatter()
for this problem.
Upvotes: 1
Views: 625
Reputation: 65460
You can specify the colors parameter to scatter
. If you simply pass the class label array as the color parameter, the colormap will be used to map each label to a corresponding RGB value.
plt.scatter(X[:,0], X[:,1], c=Y)
Upvotes: 4