title: Removing points stored in a dictionary in a matplotlib basemap animation
body: <p>I am trying to do the following: Plot points and store a reference in a dictionary. While animating remove points. A minimal example looks as follows:</p>
  
  <pre><code>%matplotlib qt
  import matplotlib.pyplot as plt
  from mpl_toolkits.basemap import Basemap
  import numpy as np
  import matplotlib.animation as animation
  
  fig = plt.figure()  
  m = Basemap(projection='aeqd',lat_0=72,lon_0=29, resolution='l',   
          llcrnrlon=15, llcrnrlat=69,
          urcrnrlon=41, urcrnrlat=75.6,area_thresh = 100)
  
  pointDict=dict()
  
  pointDict[1]=m.plot (0, 0,marker='.',label='first')[0]
  pointDict[2]=m.plot (0, 0,marker='.',label='second')[0]
  
  def init():
      print ("Init")
      x,y = m(30, 73)
      pointDict[1].set_data(x,y)
      x,y = m(31, 73)
      pointDict[2].set_data(x,y)
      return pointDict.values()
  
  def animate(i):
      print ("Frame {0}".format(i))
      if i==2:
          l=pointDict.pop(1)
          print ("Removing {0}".format(l.get_label()))
          l.remove()
          del l
      return pointDict.values()
  
  anim = animation.FuncAnimation(plt.gcf(), animate, init_func=init,
                             frames=10, interval=1000, blit=True)
  
  plt.show()
  </code></pre>
  
  <p>Output:</p>
  
  <pre><code>Init
  Init
  Frame 0
  Frame 1
  Frame 2
  Removing first
  Frame 3
  </code></pre>
  
  <p>Interestingly, if I am plotting just the first point (that is, remove pointDict[2]=m.plot and pointDict[2].set_data in the init function), this works. But if both are plotted, neither removing the first, nor the second point works.</p>
  
  <p>Related questions brought me just as far as I am now:</p>
  
  <p><a href="https://stackoverflow.com/questions/21207513/matplotlib-basemap-animation">Matplotlib Basemap animation</a></p>
  
  <p><a href="https://stackoverflow.com/questions/4981815/how-to-remove-lines-in-a-matplotlib-plot">How to remove lines in a Matplotlib plot</a></p>
  
  <p><a href="https://stackoverflow.com/questions/20624408/matplotlib-animating-multiple-lines-and-text">Matplotlib animating multiple lines and text</a></p>
  
  <p><a href="https://stackoverflow.com/questions/19519587/python-matplotlib-plot-multi-lines-array-and-animation">Python, Matplotlib, plot multi-lines (array) and animation</a></p>
  
  <p>I am using Anaconda with Python-2.7 kernel.</p>