【发布时间】:2021-03-07 15:34:28
【问题描述】:
我正在创建一个 3D 散点图,该散点图是通过使用 PCA(3 个组件)转换我的数据而产生的。我希望我的数据针对变量 'phi' 进行颜色编码,该变量是一个浮点数组,范围为 0-360 度。 变量 x :[44520,3], phi[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)
【问题讨论】:
-
x和phi的最小示例 ??请阅读minimal reproducible example。 -
试试
...c=np.squeeze(phi)...。 -
这样做将 phi 的形状从 (44520,1) 更改为 (44520,)。我不知道为什么这会有所不同,但它确实有效。感谢您的帮助
-
我如何将此主题标记为已回答?
标签: python matplotlib scatter-plot scatter3d