title: How can I make a video from array of images in matplotlib?
body: <p>I have a couple of images that show how something changes in time. I visualize them as many images on the same plot with the following code:</p>
  
  <pre><code>import matplotlib.pyplot as plt
  import matplotlib.cm as cm
  
  img = [] # some array of images
  fig = plt.figure()
  for i in xrange(6):
      fig.add_subplot(2, 3, i + 1)
      plt.imshow(img[i], cmap=cm.Greys_r)
  
  plt.show()
  </code></pre>
  
  <p>and get something like:<a href="https://i.stack.imgur.com/QX5Jm.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/QX5Jm.jpg" alt="enter image description here"></a></p>
  
  <p>Which is ok, but I would rather animate them to get <a href="https://kaggle2.blob.core.windows.net/competitions/kaggle/4729/media/heartbeat_cropped.mp4" rel="noreferrer">something like this video</a>. How can I achieve this with python and preferably (not necessarily) with matplotlib</p>