使用 Mayavi.mlab 的 3D 曲面图

3D Surface Plots Using Mayavi.mlab

我已经设法在 3D 环境中绘制多个 2D 直方图,但我想将它们绘制为 3D 表面。我一直在尝试通过使用 mayavi.mlab 的 surf 函数和 3 个一维数组来绘制它。但是当我这样做时我得到了 ZeroDivisionErrors。

这些是我的数组:

x = [-90.0, -80.0, -70.0, -60.0, -50.0, -40.0, -30.0, -20.0, -10.0, 0.0, 10.0, 20.0, 30.0, 40.0, 50.0, 60.0, 70.0 , 80.0, -90.0, -80.0, -70.0, -60.0, -50.0, -40.0, -30.0, -20.0, -10.0, 0.0, 10.0, 20.0, 30.0, 40.0, 50.0, 60.0, 70.0, 80.0, -90.0 , -80.0, -70.0, -60.0, -50.0, -40.0, -30.0, -20.0, -10.0, 0.0, 10.0, 20.0, 30.0, 40.0, 50.0, 60.0, 70.0, 80.0, -90.0, -80.0, - 70.0, -60.0, -50.0, -40.0, -30.0, -20.0, -10.0, 0.0, 10.0, 20.0, 30.0, 40.0, 50.0, 60.0, 70.0, 80.0, -90.0, -80.0, -70.0, -60.0, -50.0, -40.0, -30.0, -20.0, -10.0, 0.0, 10.0, 20.0, 30.0, 40.0, 50.0, 60.0, 70.0, 80.0, -90.0, -80.0, -70.0, -60.0, -50.0, -40.0 , -30.0, -20.0, -10.0, 0.0, 10.0, 20.0, 30.0, 40.0, 50.0, 60.0, 70.0, 80.0, -90.0, -80.0, -70.0, -60.0, -50.0, -40.0, -30.0, - 20.0, -10.0, 0.0, 10.0, 20.0, 30.0, 40.0, 50.0, 60.0, 70.0, 80.0, -90.0, -80.0, -70.0, -60.0, -50.0, -40.0, -30.0, -20.0, -10.0, 0.0、10.0、20.0、30.0、40.0、50.0、60.0、70.0、80.0、-90.0、-80.0、-70.0、-60.0、-50.0、-40.0、-30.0、-20.0、-10.0 , 0.0, 10.0, 20.0, 30.0, 40.0, 50.0, 60.0, 70.0, 80.0, -90.0, -80.0, -70.0, -60.0, -50.0, -40.0, -30.0, -20.0, -10.0, 0.0, 10.0, 20.0, 30.0, 40.0, 50.0, 60.0, 70.0, 80.0, -90.0, -80.0, -70.0, -60.0, -50.0, -40.0, -30.0, -20.0, -10.0, 0.0, 10.0, 20.0, 30.0, 40.0 , 50.0, 60.0, 70.0, 80.0, -90.0, -80.0, -70.0, -60.0, -50.0, -40.0, -30.0, -20.0, -10.0, 0.0, 10.0, 20.0, 30.0, 40.0, 50.0, 60.0, 70.0, 80.0]

y = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12]

z = [554, 310, 157, 97, 108, 169, 86, 64, 22, 20, 8, 3, 0, 0, 0, 0, 0, 0, 424, 354, 165, 112, 156, 119, 55, 39, 19, 15, 7, 0, 0, 0, 0, 0, 0, 0, 276, 455, 281, 176, 135, 98, 51, 30, 24, 17, 10, 2, 0, 0, 0, 0, 0, 0, 130, 263, 330, 283, 167, 90, 39, 30, 15, 7, 8, 4, 0, 0, 0, 0, 0, 0, 61, 168, 259, 349, 283, 116, 42, 33, 13, 13, 7, 1, 0, 0, 0, 0, 0, 0, 44, 89, 124, 239, 384, 200, 77, 31, 19, 12, 9, 0, 0, 0, 0, 0, 0, 0, 27, 61, 97, 164, 441, 315, 82, 33, 12, 11, 1, 3, 0, 0, 0, 0, 0, 0, 38, 43, 106, 227, 402, 319, 94, 20, 14, 9, 16, 2, 0, 0, 0, 0, 0, 0, 54, 91, 168, 269, 392, 224, 72, 34, 18, 9, 4, 1, 0, 0, 0, 0, 0, 0, 100, 179, 260, 361, 341, 168, 99, 54, 28, 18, 9, 1, 0, 0, 0, 0, 0, 0, 215, 277, 245, 214, 181, 143, 128, 69, 44, 15, 12, 5, 0, 0, 0, 0, 0, 0, 427, 331, 207, 162, 120, 98, 127, 80, 43, 43, 10, 2, 0, 0, 0, 0, 0, 0]

如能帮助解决我的问题,我们将不胜感激!

提前致谢。

您希望数组是二维的:

import numpy as np
x = np.array(x).reshape((12, 18))
y = np.array(y).reshape((12, 18))
z = np.array(z).reshape((12, 18))
mlab.surf(x, y, z, ...)