热线电话:13121318867

登录
2019-02-17 阅读量: 580
如何用pythonic生成3D散点图

下面的代码是一个pythonic代码,它生成一个3D散点图,其中每个数据点都有一个与其对应的簇相关的颜色。

from mpl_toolkits.mplot3d import Axes3D

import matplotlib.pyplot as plt

fig = plt.figure()

ax = fig.add_subplot(111, projection = '3d')

ax.scatter(pca_data[0], pca_data[1], pca_data[2],

c = list(map(lambda label : cluster_colors[label],

kmeans.labels_)))

str_labels = list(map(lambda label:'% s' % label, kmeans.labels_))

list(map(lambda data1, data2, data3, str_label:

ax.text(data1, data2, data3, s = str_label, size = 16.5,

zorder = 20, color = 'k'), pca_data[0], pca_data[1],

pca_data[2], str_labels))

plt.show()

25.7508
3
关注作者
收藏
评论(0)

发表评论

暂无数据
推荐帖子