What´s up everyone! Ultimately, I have been working with python,learning the basics of animations using matplotlib. The code is quite simple:
import random
from itertools import count
import pandas as pd
import matplotlib.pyplot as plt
from matplotlib.animation import FuncAnimation
plt.style.use('fivethirtyeight')
x_vals = []
y_vals = []
index = count()
def animate(i):
x_vals.append(next(index))
y_vals.append(random.randint(0, 5))
plt.cla() # cla: clear axis
plt.plot(x_vals,y_vals)
ani = FuncAnimation(plt.gcf(),animate, interval=1000)
plt.tight_layout()
plt.show()
When I compile the code, no error is found but for this comment:
/home/der/.local/lib/python3.8/site-packages/matplotlib/animation.py:973: UserWarning: Animation was deleted without rendering anything. This is most likely unintended. To prevent deletion, assign the Animation to a variable that exists for as long as you need the Animation.
warnings.warn(
<Figure size 432x288 with 0 Axes>
How can I fix it? Your help is invaluable to me since I have been scrumbling for a week.