首页 > 解决方案 > 使用来自 3D 数组的 matplotlib.animation.funcanimation 的 3d 动画

问题描述

我试图制作在 python 中传播的 2d 波的 3d 动画,z 轴是波的电场幅度。x 和 y 是一个网格,在该点处测量 t 时刻的幅度,因此 EzTot 是一个 3d 数组,其中 t = 0,..,500 的幅度值(在时间 t 的网格中 (x,y) 处的幅度)由 EzTot[t][x,y]) 给出。我想从时间 0 到 500 动画这个幅度,但我不知道如何。您可以在下面看到时间 500 处波幅的 3d 表面图的代码。

y = range(NY)
z = EzTot[500]
fig = plt.figure()
ax = Axes3D(fig)
x, y = np.meshgrid(x, y)
ax.plot_surface(x, y, z, rstride=1, cstride=1, cmap='hot') ```
plt.show

标签: pythonmatplotlibanimationmultidimensional-array

解决方案


推荐阅读