3d如何绘制usinf matplotlib?

时间:2019-11-02 02:35:40

标签: matplotlib

我试图绘制一组来自PCA的降维数据的图,如下所示:

pca = PCA(n_components=3)
transformed=pca.fit_transform(datas) 
PCA(copy=True, iterated_power='auto', n_components=2, random_state=None,
    svd_solver='auto', tol=0.0, whiten=False)

fig = plt.figure()
ax = Axes3D(fig)
Axes3D.scatter(np.array(transformed[:,0]), np.array(transformed[:,1]), np.array(transformed[:,2]), zdir='z', s=20, c=None, depthshade=True)

但是,我遇到以下错误:

<ipython-input-10-cf5b7bef4dd1> in <module>
     77 fig = plt.figure()
     78 ax = Axes3D(fig)
---> 79 Axes3D.scatter(np.array(transformed[:,0]), np.array(transformed[:,1]), np.array(transformed[:,2]), zdir='z', s=20, c=None, depthshade=True)
     80 
     81 print(transformed)

/opt/conda/lib/python3.6/site-packages/mpl_toolkits/mplot3d/axes3d.py in scatter(self, xs, ys, zs, zdir, s, c, depthshade, *args, **kwargs)
   2295         """
   2296 
-> 2297         had_data = self.has_data()
   2298 
   2299         xs, ys, zs = np.broadcast_arrays(

AttributeError: 'numpy.ndarray' object has no attribute 'has_data'

0 个答案:

没有答案