title: Python - Animating large dataset with matplotlib
body: <p>For a personal project, I'm trying to animate a fairly large data set (1000 rows) to show multiple bird dives in Jupyter notebook. Eventually I'd also like to add subplots of acceleration data along with it.</p>
  
  <p>I used simple examples as a rough template, such as the growing coil example in: <a href="https://towardsdatascience.com/animations-with-matplotlib-d96375c5442c" rel="nofollow noreferrer">https://towardsdatascience.com/animations-with-matplotlib-d96375c5442c</a></p>
  
  <p>The code itself seems to run slow but fine, however it doesn't output an animation, just a static graph:
  <a href="https://i.stack.imgur.com/2mAeW.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/2mAeW.png" alt="enter image description here"></a></p>
  
  <p>Here's my current code:</p>
  
  <pre><code>x = np.array(dives.index)
  y = np.array(dives['depth'])
  x_data, y_data = [], []
  
  fig = plt.figure()
  ax = plt.axes(xlim=(0, 1000), ylim=(min(y),max(y)))
  line, = ax.plot([], [])
  
  def init():
      line.set_data([], [])
      return line,
  
  def animate(i):
      x_data.append(x[i])
      y_data.append(y[i])
      line.set_data(x, y)
  
      return line,
  
  plt.title('Bird Dives') 
  
  ani = animation.FuncAnimation(
      fig, animate, init_func=init, frames= 1000, interval=50, blit=True)
  
  ani.save('./plot-test.gif')
  plt.show()
  </code></pre>
  
  <p>Is there a reason why it's just plotting a graph rather than an animated one?</p>