Hi, I'm trying to animate an imshow() plot. Here is my example:
------ import numpy as np from numpy import pi from mayavi import mlab Nx = 200 Ny = 200 N = 100 u0 = np.zeros((Nx,Ny)) nx = np.arange(Nx) ny = np.arange(Ny) nx = nx[:,None] amp = 2.0 c = 10.0 Ts = 1/30.0 v = np.array([2,1]) @mlab.animate(ui=False,delay=100) def main_loop(): for n in range(0,N): u0 = amp*np.sin(2*pi*(nx/Nx*v[0] + ny/Ny*v[1]) - c*n*Ts) #plotting if n==0: mlab.clf() fig = mlab.gcf() X,Y = np.mgrid[0:Nx,0:Ny] #h1 = mlab.surf(X,Y,u0,vmax=amp,vmin=-amp) h1 = mlab.imshow(u0,vmax=amp,vmin=-amp) mlab.axes(xlabel='x', ylabel='y', zlabel='z', nb_labels=5, color=(0., 0., 0.)) mlab.outline() mlab.colorbar() mlab.draw() else: h1.mlab_source.scalars = u0 mlab.draw() print('n=%d' % n) yield a = main_loop() mlab.show() ------ I'm not sure that 'h1.mlab_source.scalars = u0' is the correct way to update the imshow plot, but it doesn't seem to throw an error, yet the plot doesn't update. If you comment out the line with 'imshow', and uncomment the line with 'surf', you'll get an idea of what it should look like animated. I couldn't find anything in the documentation regarding this. The only thing I found was this unsolved SO post: https://stackoverflow.com/questions/40168623/how-to-animate-imshow-by-maya Any help would be appreciated! Appreciate all the hard work put into this! Best, -- Brian _______________________________________________ MayaVi-users mailing list MayaVi-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/mayavi-users