title: Animated Scatter Plot
body: <p>I would like to do an animation in python representing each point, dot by dot.  I am doing it as I always have done it, but it does not work. Any help? 
  I tried 2 different ways.</p>
  
  <pre><code>import matplotlib.pyplot as plt
  from matplotlib.animation import FuncAnimation
  
  %matplotlib nbagg
  
  def mcd(a, b):
      resto = 0
      while(b &gt; 0):
          resto = b
          b = a % b
          a = resto
      return a
  
  N = 1200
  
  n = list (range (N))
  an = [1,1]
  
  for i in range (2,N):
      k = i-1
      if mcd (n[i], an[k]) == 1:
          an.append (n[i] + 1 + an[k])
      else:
          an.append (an[k]/mcd (n[i], an[k]))
  
  fig = plt.figure ()
  ax = fig.add_subplot (111)
  ax.grid (True)
  ax.set_xlim(0, N*1.1)
  pt, = ax.plot ([],[],'ko', markersize=2)
  
  ax.plot (n,an, 'ko', markersize=2)
  
  def init ():
  
      pt.set_data([],[])
      return (pt)
  
  def animate (i,pt):
  
      pt.set_data (n[:i],an[:i])
  
      return (pt)
  
  ani = FuncAnimation (fig, animate, fargs = (pt), frames=N, init_func=init, interval=50, blit = True)
  
  plt.show ()
  </code></pre>
  
  <p>And the second way:</p>
  
  <pre><code>import matplotlib.pyplot as plt
  from matplotlib.animation import FuncAnimation
  
  %matplotlib nbagg
  
  def mcd(a, b):
      resto = 0
      while(b &gt; 0):
          resto = b
          b = a % b
          a = resto
      return a
  
  N = 1200
  
  n = list (range (N))
  an = [1,1]
  
  for i in range (2,N):
      k = i-1
      if mcd (n[i], an[k]) == 1:
          an.append (n[i] + 1 + an[k])
      else:
          an.append (an[k]/mcd (n[i], an[k]))
  
  xdata, ydata = [],[]
  
  fig = plt.figure ()
  ax = fig.add_subplot(111)
  ax.grid (True)
  pt, = ax.plot ([],[],'ko', markersize=2)
  
  ax.plot (n,an, 'ko', markersize=2)
  
  def init ():
      ax.set_xlim(0, N*1.1)
      pt.set_data([],[])
      return (pt)
  
  def animate (pt):
      xdata.append (n[i])
      ydata.append (an[i])
  
      pt.set_data (xdata,ydata)
  
      return (pt)
  
  ani = FuncAnimation (fig, animate, fargs = (pt), frames=N, init_func=init, interval=50, blit = True)
  
  plt.show ()
  </code></pre>
  
  <p>Using those codes, I get the entire figure with all the points. I would like to fill the graph point by point in an animated way.</p>