Animated contour plot from 3D numpy array Python -


i have 3d array has 1 time index , 2 space indices. trying animate on first index visualize 2d solution in time. found stack question here, not entirely sure how resolved, i'm still little confused. have solution array a[n,i,j] n time index, , x , y spacial indices. mentioned want animate on 2d arrays a[:,i,j]. how use animation module in matplotlib this?

here's example based on 1 linked data in format describe:

from matplotlib import pyplot plt import numpy np matplotlib import animation  # fake data x = y = np.arange(-3.0, 3.01, 0.025) x, y = np.meshgrid(x, y) s = np.shape(x) nframes = 20 = np.zeros((nframes, s[0], s[1])) in range(1,21):      a[i-1,:,:] = plt.mlab.bivariate_normal(x, y, 0.5+i*0.1, 0.5, 1, 1)  # set plotting fig = plt.figure() ax = plt.axes()    # animation function def animate(i):      z = a[i,:,:]     cont = plt.contourf(x, y, z)      return cont    anim = animation.funcanimation(fig, animate, frames=nframes) plt.show() 

Comments

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -