title: Redrawing a plot in IPython / matplotlib
body: <p>I use IPython/Matplotlib, and I want to create functions that can plot various graphs in the same plotting window.  However, I have trouble with redrawing.  This is my program <code>test_plot_simple.py</code>:</p>
  
  <pre><code>from __future__ import division
  import numpy as np
  import matplotlib.pyplot as plt
  
  x = np.arange(10)
  y2 = (x**2)/(10**2)
  ye = (2**x)/(2**10)
  fig, ax = plt.subplots()
  
  def p_squared():
      ax.plot(x,y2, 'r')
      plt.show()
  
  def p_exp():
      ax.plot(x,ye, 'r')
      plt.show()
  </code></pre>
  
  <p>I start IPython as <code>$ python --matplotlib</code></p>
  
  <p>On the IPython command line I do</p>
  
  <pre><code>In [1]: run test_plot_simple.py
  In [2]: p_squared()
  In [3]: p_exp()
  </code></pre>
  
  <p>After the second line, the squared graph is shown.  But nothing happens after the second.  Why is the <code>plt.show()</code> not working here?</p>