title: How to reset matplotlib animation without re-running script
body: <p>I'm using matplotlib's FuncAnimation function to animate a segment of a large dataset:</p>
  
  <pre><code>fig = plt.figure(figsize=(15, 11.5))
  ax = fig.add_subplot(111, aspect='equal', autoscale_on=False,
                       xlim=(x1,x2), ylim=(y1, y2))
  
  data,=ax.plot([],[],'o')
  
  def init():
      data.set_data([],[])
      return data
  
  
  def animate(t):
      global x_pos,y_pos
      data.set_data(x_pos[t],y_pos[t])
      return data
  
  ani=animation.FuncAnimation(fig,animate,frames=duration,interval=20,
                              init_func=init,blit=True)
  
  
  plt.show()
  </code></pre>
  
  <p>When I run my code from scratch this works great. However, since that involves loading up and preprocessing a large dataset it takes a few minutes, so I'd like to be able to run just a segment of my code to test and animate. </p>
  
  <p>When I close my animation and try running it again, however, I'm left with only a blank figure - no points are plotted and the animate() function is never called (I tested this with a print statement).</p>
  
  <p>I tried clearing the plot and the figure:</p>
  
  <pre><code>plt.clf()
  fig.close()
  plt.clear(figure)
  </code></pre>
  
  <p>and trying a different figure number, but the results are the same.</p>
  
  <p>How can I clear the animation so that I can run it again without re-running my entire script?</p>