title: Animating contourf plot
body: <p>I am trying to animate a contour plot. The following example is close enough to what I want to achieve (from <a href="https://www.mail-archive.com/matplotlib-users@lists.sourceforge.net/msg17614.html" rel="nofollow">this archive</a>):</p>
  
  <pre><code>import matplotlib.pyplot as plt
  import numpy as np
  
  x = np.arange(0, 2 * np.pi, 0.1)
  X,Y = np.meshgrid(x,x)
  f1 = np.sin(X) + np.sin(Y)
  f2 = np.cos(X) + np.cos(Y)
  
  plt.figure()
  C = plt.contourf(f1)
  plt.show()
  
  for coll in C.collections:
      plt.gca().collections.remove(coll)
  
  C = plt.contourf(f2)
  plt.draw()
  </code></pre>
  
  <p>However, there seems to be an issue with the <code>remove</code> command and I'm not sure how to fix it.</p>