title: How do I plot in real-time in a while loop using matplotlib?
body: <p>I am trying to plot some data from a camera in real time using OpenCV. However, the real-time plotting (using matplotlib) doesn't seem to be working.</p>
  
  <p>I've isolated the problem into this simple example:</p>
  
  <pre><code>fig = plt.figure()
  plt.axis([0, 1000, 0, 1])
  
  i = 0
  x = list()
  y = list()
  
  while i &lt; 1000:
      temp_y = np.random.random()
      x.append(i)
      y.append(temp_y)
      plt.scatter(i, temp_y)
      i += 1
      plt.show()
  </code></pre>
  
  <p>I would expect this example to plot 1000 points individually. What actually happens is that the window pops up with the first point showing (ok with that), then waits for the loop to finish before it populates the rest of the graph.</p>
  
  <p>Any thoughts why I am not seeing points populated one at a time?</p>