title: Python: matplotlib - loop, clear and show different plots over the same figure
body: <p>I want to see how a plot varies with different values using a loop. I want to see it on the same plot. But i do not want to remains of the previous plot in the figure. In MATLAB this is possible by creating a figure and just plotting over the same figure. Closing it when the loop ends. </p>
  
  <p>Like,</p>
  
  <pre><code>fh = figure();
  %for loop here
  %do something with x and y    
  subplot(211), plot(x);
  subplot(212), plot(y); 
  pause(1)
  %loop done
  close(fh);
  </code></pre>
  
  <p>I am not able to find the equivalent of this in matplotlib. Usually all the questions are related to plotting different series on the same plot, which seems to come naturally on matplotlib, by plotting several series using <code>plt.plot()</code> and then showing them all finally using <code>plt.show()</code>. But I want to refresh the plot. </p>