title: Clear figure subplots matplotlib python
body: <p>I wrote a simple Python function to generate a matplotlib figure.  I call <code>plotData</code> multiple times from a separate script, but each time it generates a new plot.  What I would like is to always have just one plot with something like <code>subplot.clear()</code> to clear the subplots between data changes.</p>
  
  <p>I need a way to identify the figure from outside <code>plotData</code> so that I can clear the plots for new data.  What would be the best way to accomplish this?</p>
  
  <pre><code>## Plot Data Function
  def plotData(self):
  
          # Setup figure to hold subplots
          f = Figure(figsize=(10,8), dpi=100)
  
          # Setup subplots
          subplot1=f.add_subplot(2,1,1)
          subplot2=f.add_subplot(2,1,2)
  
          # Show plots
          dataPlot = FigureCanvasTkAgg(f, master=app)
          dataPlot.show()
          dataPlot.get_tk_widget().pack(side=RIGHT, fill=BOTH, expand=1)
  </code></pre>