python - 是否想在python中使用机器学习来增加质心点?-LMLPHP我想增加质心点的大小。下面是我的代码。

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

最佳答案

在plt.scatter方法中,您想要提供一个s参数来定义点的面积,如此处在此问题中所讨论的:pyplot scatter plot marker size

因此,您的最后一个循环将需要如下所示:

for i in centroids.keys():
  plt.scatter(*centroids[i], color=colmap[i], s=4) # change the s= parameter

关于python - 是否想在python中使用机器学习来增加质心点?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/55453939/

10-12 18:38