0

enter image description hereI want to increase the size of centroids points. Below is the my code.

centroids = {
    i+1: [np.random.randint(0,80), np.random.randint(0,80)]
    for i in range(k)
}
fig = plt.figure(figsize=(10, 5))
plt.scatter(df['x'], df['y'], color='k')
colmap = {1: 'r', 2: 'g', 3: 'b'}
for i in centroids.keys():
    plt.scatter(*centroids[i], color=colmap[i])
Naeem
  • 259
  • 2
  • 7
  • 18

1 Answers1

1

In the plt.scatter method you want to provide an s parameter to define the area of the points as discussed in this question here : pyplot scatter plot marker size

Thus your last loop would need to look like:

for i in centroids.keys():
  plt.scatter(*centroids[i], color=colmap[i], s=4) # change the s= parameter
AverageJoe
  • 26
  • 3
  • s = 4 is somewhat too small as it measures the area of the marker. I would normally put s = 64-100. – Tu Bui Apr 01 '19 at 13:00