title: How to do dynamic matplotlib plotting with a fixed pandas dataframe?
body: <p>I have a dataframe called <code>benchmark_returns</code> and <code>strategy_returns</code>. Both have the same timespan. I want to find a way to plot the datapoints in a nice animation style so that it shows all the points loading in gradually. I am aware that there is a <code>matplotlib.animation.FuncAnimation()</code>, however this typically is only used for a real-time updating of csv files etc but in my case I know all the data I want to use. </p>
  
  <p>I have also tried using the crude <code>plt.pause(0.01)</code> method, however this drastically slows down as the number of points get plotted.  </p>
  
  <p>Here is my code so far </p>
  
  <pre><code>x = benchmark_returns.index
  y = benchmark_returns['Crypto 30'] 
  y2 = benchmark_returns['Dow Jones 30']
  y3 = benchmark_returns['NASDAQ'] 
  y4 = benchmark_returns['S&amp;P 500']
  
  
  fig, ax = plt.subplots()
  line, = ax.plot(x, y, color='k')
  line2, = ax.plot(x, y2, color = 'b')
  line3, = ax.plot(x, y3, color = 'r')
  line4, = ax.plot(x, y4, color = 'g')
  
  def update(num, x, y, y2, y3, y4, line): 
      line.set_data(x[:num], y[:num])
      line2.set_data(x[:num], y2[:num])
      line3.set_data(x[:num], y3[:num])
      line4.set_data(x[:num], y4[:num])
  
      return line, line2, line3, line4,
  
  ani = animation.FuncAnimation(fig, update, fargs=[x, y, y2, y3, y4, line], 
                                interval = 1, blit = True)
  plt.show()
  </code></pre>