title: Extra Frame in matplotlib.animation.FuncAnimate
body: <p>I am exploring live graphs with matplotlib animations. Currently, I'm just adding a random integer to an array, and having my plot update based on the new number. The issue is that I seem to be getting an extra value drawn to the plot.</p>
  <p>I have the following code:</p>
  <pre class="lang-py prettyprint-override"><code>import matplotlib.pyplot as plt
  import matplotlib.animation as animation
  import random
  
  fig = plt.figure()
  ax1 = fig.add_subplot(1, 1, 1)
  
  xs = []
  ys = []
  
  def animate(i, xs, ys):
      
      x = i + 1
      y = random.randint(1, 50)
      
      print '{}: {}, {}'.format(i, x, y)
      
      xs.append(x)
      ys.append(y)
              
      ax1.clear()
      ax1.plot(xs, ys)
          
  ani = animation.FuncAnimation(fig,
                                animate,
                                frames = 10,
                                fargs = (xs, ys),
                                repeat = False)
  plt.show()
  </code></pre>
  <p>I only want 10 values to be drawn, so I set <code>frames = 10</code> in the <code>FuncAnimate</code> call. However, the print statement is outputting an 11th value:</p>
  <p><a href="https://i.stack.imgur.com/kmqUw.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/kmqUw.png" alt="Plot Result" /></a></p>
  <p><a href="https://i.stack.imgur.com/izFdl.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/izFdl.png" alt="Print Statement Output" /></a></p>
  <p>So it's clear that 11 frames are being generated, rather than 10.  Looking at the documenation for <a href="https://matplotlib.org/api/_as_gen/matplotlib.animation.FuncAnimation.html#matplotlib.animation.FuncAnimation" rel="nofollow noreferrer">FuncAnimate</a>, I can't see a reason why this would be happening.</p>
  <p>Can anyone tell me what I'm missing?</p>
  <p>Thanks!</p>