![](/img/trans.png)
[英]How to plot a 3d surface from multiple 2d arrays and one 1d array?
[英]How to plot a 3D surface Plot using three 1D arrays in python as I am getting an error Z must be in 2 dimensional. How to convert it into 2D array?
我试图用三个随机的一维阵列创建一个表面图
`
Z = [7.209, 7.223, 7.229, 7.236, 7.243, 7.27, 7.277, 7.284, 7.292, 7.306,
7.312, 7.329, 7.337, 7.347, 7.354, 8.356, 8.363, 8.374, 8.39, 8.398]
X = np.random.rand(20)
Y = np.random.rand(20)
X, Y = np.meshgrid(X,Y)
ax.plot_surface(X,Y,Z,rstride=4,cstride=4, cmap=plt.cm.coolwarm)
`
我收到一个错误
if Z.ndim != 2:
AttributeError: 'list' object has no attribute 'ndim'
如何绘制Z值不是X和Y的函数的3D表面图。
点之间没有连接。 它们是3个独立的一维数组,其中X具有20个点,Y具有20个点,Z具有20个点。 我做网格物体的唯一原因是将1D数组转换为2D阵列,这是绘制表面图的要求,而我没有得到如何在X和Y的那个网格物体上绘制Z值的方法。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.