Reputation: 245
i read the book "Machine Learning Algorithms" from Packt and there is a code sample which i tried to reproduce. I have some problems with the color of the markers inside this scatter plot.
The code is the following:
from sklearn.datasets import make_circles
nb_samples = 500
X, Y = make_circles(n_samples=nb_samples, noise=0.1)
This produces a circle with data. The picture in the book looks like that:
I tried to reproduce this with:
from sklearn.datasets import make_circles
import matplotlib.pyplot as plt
nb_samples = 500
X, Y = make_circles(n_samples=nb_samples, noise=0.1)
plt.scatter(X[:, 0], X[:, 1])
plt.show()
And the output is the following:
I want to know how to set a different color and markers for the data points. Maybe my code is wrong and i shouldn't plot X[:, 0], X[:, 1]. I hope someone can help me.
Upvotes: 1
Views: 583
Reputation: 339052
The color is supposedly produced by the other return value of make_circles
. Hence
plt.scatter(X[:, 0], X[:, 1], c=Y, cmap="bwr")
Upvotes: 2