I am trying to animate imshow() (i.e., change image over time) with mayavi, following the method to animate points3d (Animating a mayavi points3d plot), but the scene never updates. The following code continues showing the same (initial) image, which I set to zeros.
Your help very much appreciated!
note: I know how to do this in matploblib (matplotlib imshow(): how to animate?). I want to do it now in mayavi.
My environment is: Ubuntu 16.04 python 2.7.12 / ipython 4.2.0 (both failed)
import numpy as np
from mayavi import mlab
@mlab.animate(delay=10)
def main():
s = np.zeros((2,2))
im = mlab.imshow(s, colormap='gist_earth')
for i in range(100):
print i
s += np.random.random((2,2))
im.mlab_source.set(scalars=s)
yield
main()
mlab.show()