我正在尝试3D图。我已经在2d中有了这张图。 它是具有波振幅的矩阵。但我想在3d图中将此值绘制为'z'
我试图更改代码中的尺寸,但没有成功。
xx, yy = np.mgrid[1:333, 1:116]
fig = plt.figure(figsize=(13,7))
ax = plt.axes(projection='3d')
surf = ax.plot_surface(xx, yy, vals2[100], rstride=1, cstride=1, cmap='RdBu', edgecolor='none')
ax.set_xlabel('x')
ax.set_ylabel('y')
ax.set_zlabel('Intensity')
ax.set_title('Wave propagation inside waveguide')
fig.colorbar(surf, shrink=0.5, aspect=5) # add color bar
ax.view_init(60,35)
plt.savefig('figuraTeste3d.png', format='png')
plt.show()
上面,矩阵维是len(vals) = 333
和len(vals[2]) = 116
。
与surf = ax.plot_surface...
一起乞求,我收到此消息:
ValueError: Shape mismatch: objects cannot be broadcast to a single shape
我该如何解决?