2020-11-05
阅读量:
597
我想用pythonic绘制一个3D散点图,怎样实现呢?
问题详述:我想用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()






评论(0)


暂无数据
推荐帖子
0条评论
0条评论
0条评论