'How do I animate this graph to just display the next row
So I tried this, I'm working in a jupyter notebook and am wondering how to animate the next row of data.
enter code here
def animate(i):
data = df.iloc[i]
return data
ani = matplotlib.animation.FuncAnimation(fig, animate, frames=53, interval=700, repeat=True)
Solution 1:[1]
For what I can see in the documentation you have to set the plot data inside the animate function. You must also have an instance to your plot and use that same instance inside the animate function.
fig, ax = plt.subplots()
p, = plt.plot(df.columns, df.iloc[0])
def animate(i):
print(df.iloc[i])
p.set_data(df.columns, df.iloc[i])
return p
ani = matplotlib.animation.FuncAnimation(fig, animate, frames=20, interval=10, blit=True, repeat=True)
plt.show()
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | DollarAkshay |
