I have about 8 months worth of hourly data that I want to plot in an animation style. I am currently able to do that, however it gets extremely slow as the quantity of data increases. Note that I have even set the interval to only 1ms! Is there anyway to ensure that the animation doesn't slow down? Furthermore, how can I plot multiple lines at the same time in this style?
Here is my code so far:
x = benchmark_returns.index
y = benchmark_returns['Crypto 30']
#Would preferrably like to plot
#benchmark_returns[['Crypto 30', 'NASDAQ', 'Dow Jones 30', 'S&P 500']] at the same time
fig, ax = plt.subplots()
line, = ax.plot(x, y, color='k')
def update(num, x, y, line):
line.set_data(x[:num], y[:num])
return line,
ani = animation.FuncAnimation(fig, update, fargs=[x, y, line],
interval = 1, blit=True)
plt.show()
Here is an example of my dataframe:
Crypto 30 Dow Jones 30 NASDAQ S&P 500
2019-06-09 00:00:00 100.00000 100.0 100.0 100.0
2019-06-09 01:00:00 95.78653 100.0 100.0 100.0
2019-06-09 02:00:00 95.78653 100.0 100.0 100.0
2019-06-09 03:00:00 95.78653 100.0 100.0 100.0
2019-06-09 04:00:00 95.78653 100.0 100.0 100.0
2019-06-09 05:00:00 95.78653 100.0 100.0 100.0
2019-06-09 06:00:00 95.78653 100.0 100.0 100.0
2019-06-09 07:00:00 95.78653 100.0 100.0 100.0
2019-06-09 08:00:00 95.78653 100.0 100.0 100.0
2019-06-09 09:00:00 95.78653 100.0 100.0 100.0
xandy.x = np.arange(1_000_000); y = np.sin(x/10).