1

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.

1 Answer 1

4

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)
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.