title: How to update matplotlib's imshow() window interactively?
body: <p>I'm working on some computer vision algorithm and I'd like to show how a numpy array changes in each step.</p>
  
  <p>What works now is that if I have a simple <code>imshow( array )</code> at the end of my code, the window displays and shows the final image.</p>
  
  <p>However what I'd like to do is to update and display the imshow window as the image changes in each iteration. </p>
  
  <p>So for example I'd like to do:</p>
  
  <pre><code>import numpy as np
  import matplotlib.pyplot as plt
  import time
  
  array = np.zeros( (100, 100), np.uint8 )
  
  for i in xrange( 0, 100 ):
      for j in xrange( 0, 50 ):
          array[j, i] = 1
  
          #_show_updated_window_briefly_
          plt.imshow( array )
          time.sleep(0.1)
  </code></pre>
  
  <p>The problem is that this way, the Matplotlib window doesn't get activated, only once the whole computation is finished.</p>
  
  <p>I've tried both native matplotlib and pyplot, but the results are the same. For plotting commands I found an <code>.ion()</code> switch, but here it doesn't seem to work.</p>
  
  <p>Q1. What is the best way to continuously display updates to a numpy array (actually a uint8 greyscale image)?</p>
  
  <p>Q2. Is it possible to do this with an animation function, like in the <a href="http://matplotlib.org/examples/animation/dynamic_image.html">dynamic image example</a>? I'd like to call a function inside a loop, thus I don't know how to achieve this with an animation function.</p>