【发布时间】:2017-12-02 22:33:17
【问题描述】:
我正在尝试使用 mplot3d 绘制散点图,但 scatter 方法给出了值错误:“xs”和“ys”必须具有相同的大小。 当我打印它们的类型和尺寸时,它们看起来很完美。我无法弄清楚出了什么问题。
这是我的代码的一部分:
'mat2' 是 512 X 4 个已经计算好的矩阵。
mat2 = np.array(mat2)
fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
co = []
xx = mat2[:,:1]
yy = mat2[:,:2]
z = mat2[:,:3]
co = mat2[:,:4]
#printing the size and types of the arguments to the scatter()
print(str(len(xx))+str(type(xx))+' '+str(len(yy))+str(type(yy))+' '+str(len(z))+' '+str(len(co)))
ax.scatter(np.array(xx), np.array(yy), z=np.array(z), c=np.array(co), cmap=plt.hot())
这是我得到的输出截图 - ValueError Screenshot
有什么帮助吗?
【问题讨论】:
-
查询错误时,需要提供问题的minimal reproducible example。
-
对不起。新来的。
标签: python-3.x matplotlib scatter-plot mplot3d valueerror