3D散点图matplotlib,向绘图添加颜色无效?

2024-09-29 21:24:50 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在创建一个3D散点图,该散点图是使用PCA(3个组件)转换数据的结果。我希望我的数据根据变量“phi”进行颜色编码,这是一个浮动数组,范围为0-360度。 变量x:[44520,3],φ[44520,1]

我得到以下错误:

ValueError: 'c' argument has 44520 elements, which is not acceptable for use with 'x' with size 44520, 'y' with size 44520.

有什么线索吗


signalt = dfonf.T # transpose the data as the cell #s are the features and the sampled data is the sample
pca = PCA(n_components=3)

x = pca.fit_transform(signalt)

fig = plt.figure(figsize=(10, 10))
ax = plt.axes(projection="3d")
pcaplot = ax.scatter3D(x[:,0],x[:,1],x[:,2],c=phi,s=0.2)
cbar = fig.colorbar(pcaplot)

Tags: the数据datasizeiswithfig组件

热门问题