I would like to make matrix movie, but 'AxesImage' object is not iterable
<p>This code is matplotlib. </p>

<p>=======</p>

<pre><code>import numpy as np
import matplotlib.pyplot as plt
import matplotlib.animation as animation

fig2 = plt.figure()

x = np.arange(-9, 10)
y = np.arange(-9, 10).reshape(-1, 1)
base = np.hypot(x, y)
ims = []
for add in np.arange(30):
    ims.append((plt.pcolor(x, y, base + add, norm=plt.Normalize(0, 50)),))

im_ani = animation.ArtistAnimation(fig2, ims, interval=50, repeat_delay=3000,
                                   blit=True)
#im_ani.save('im.mp4', metadata={'artist':'Guido'})
im_ani.save('basic_example.gif', writer='imagemagick')

plt.show()
</code></pre>

<p><img src="https://i.stack.imgur.com/LE0HC.gif" alt="example"></p>

<p>I would like to change from plt.pcolor to plt.matshow because I have to visualize matrix changing.</p>

<pre><code>import numpy as np
import matplotlib.pyplot as plt
import matplotlib.animation as animation

fig = plt.figure()

a = np.zeros(3)
b = np.identity(3)
a = np.matrix(a)
b = np.matrix(b)

ims = []
for i in np.arange(5):
    w = a + i*b
    w = w.tolist()
    ims.append(plt.matshow(a + i*b))

ani = animation.ArtistAnimation(fig, ims)
plt.show()
</code></pre>

<p>The error message is this:</p>

<pre><code>TypeError
Traceback (most recent call last)
/Users/~/simple_anim_matrix.py in &lt;module&gt;()
    152     ims.append(plt.matshow(a + i*b))
    153 
--&gt; 154 ani = animation.ArtistAnimation(fig, ims)
    155 
    156 #ani.save('demo4.mp4')

/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/matplotlib/animation.pyc in __init__(self, fig, artists, *args, **kwargs)
    932         # over by the machinery.
    933         self._framedata = artists
--&gt; 934         TimedAnimation.__init__(self, fig, *args, **kwargs)
    935 
    936     def _init_draw(self):

/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/matplotlib/animation.pyc in __init__(self, fig, interval, repeat_delay, repeat, event_source, *args, **kwargs)
    876 
    877         Animation.__init__(self, fig, event_source=event_source,
--&gt; 878                            *args, **kwargs)
    879 
    880     def _step(self, *args):

/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/matplotlib/animation.pyc in __init__(self, fig, event_source, blit)
    557 
    558         # Clear the initial frame
--&gt; 559         self._init_draw()
    560 
    561         # Instead of starting the event source now, we connect to the figure's

/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/matplotlib/animation.pyc in _init_draw(self)
    938         axes = []
    939         for f in self.new_frame_seq():
--&gt; 940             for artist in f:
    941                 artist.set_visible(False)
    942                 # Assemble a list of unique axes that need flushing

TypeError: 'AxesImage' object is not iterable
</code></pre>