title: How to animate graph of data in python using matplotlib.animation
body: <p>I have two arrays x and y, each one has more than 365000 elements. I would like to draw an animated line using these array elements. I'm using matplotlib.animation for it. Problem is when I execute the code below I can't see the graph smoothly(animated) drawed. Contrary I see it's final drawed version.</p>
  
  <p><img src="https://i.stack.imgur.com/5lfH5.gif" alt="This is what I obtain"></p>
  
  <p>Here is my code:</p>
  
  <pre><code>#libs
  # Movement instance creation-----------------------------
  movement1=Movement(train1, track1)
  # # Move the train on the track
  
  movement1.move()
  y = movement1.speed
  x = movement1.pos
  
  Writer = animation.writers['ffmpeg']
  writer = Writer(fps=20, metadata=dict(artist='Me'), bitrate=1800)
  
  fig = plt.figure()
  ax = plt.axes(xlim=(0, 25), ylim=(0, 300))
  line, = ax.plot([], [], lw=2)
  # initialization function: plot the background of each frame
  def init():
      line.set_data([], [])
      return line,
  
  # animation function.  This is called sequentially
  def animate(i):
      line.set_data(x, y)
      return line,
  
  anim = animation.FuncAnimation(fig, animate, init_func=init,
                                  frames=200, interval=200, blit=True)
  
  
  anim.save('basic_animation.mp4', writer=writer)
  </code></pre>
  
  <p>Here is the similar result that I expect:</p>
  
  <p><img src="https://i.stack.imgur.com/Gd7Uq.gif" alt="Here is the similar result that I expect. "></p>
  
  <p>Of course my graph would be another curve.</p>