【发布时间】:2017-08-16 15:29:54
【问题描述】:
我正在使用 plotly(当我悬停时能够获取点信息)来可视化我的聚类散点图。我无法为使用 KMeans 生成的集群分配不同的颜色。在 matplotlib.pyplot(作为 plt)中绘制它时,我使用以下代码:
plt.scatter(restult[:,0], result[:,1], c=cluster_labels
cluster_labels 是:
n_clusters = 3
km = KMeans(n_clusters).fit(result)
labels = km.labels_
它工作得很好,但我需要胡佛信息。
这就是我到目前为止的情节:
trace = go.Scatter(
x = result[:,0],
y = result[:,1],
mode = 'markers',
text = index, # I want to see the index of each point
)
data = [trace]
# Plot and embed in ipython notebook!
py.iplot(data, filename='basic-scatter')
感谢您的帮助!
【问题讨论】:
标签: python-2.7 cluster-computing plotly scatter-plot