Beginner-Make a frame based video in python from figures

Viewed 2804

I plot figures in a for loop which is a loop for my time, basically at each time step I plot a surf out of my data as below:

for time_step in range(0,nt):
    fig = plt.figure()
    ax = fig.add_subplot(111, projection='3d')
    x = np.arange(xmin, xmax+dx, dx)
    z = np.arange(zmin, zmax+dz, dz)
    X, Z = np.meshgrid(x, z)
    ax.plot_surface(X, Z, w1[time_step])
    plt.show()

Suppose that w1[time_step] changes in the loop and is sth different at each time step, all other assumptions you can have. I plot but don't know only how to make them into a video.

I have done it matlab, but I want to do sth similar in Python

1 Answers
Related