几天前,我开始学习matplotlib
,并且编写了无效的代码。你能帮我吗。这是代码:
import matplotlib.pyplot as plt
from itertools import count
from matplotlib.animation import FuncAnimation
import random
index = count()
x1 = []
y1 = []
def animate(i):
x1.append(next(index))
y1.append(random.randint(-5, 12))
plt.cla()
plt.plot(x1, y1)
FuncAnimation(plt.gcf(), animate, interval = 1000)
plt.tight_layout()
plt.show()
谢谢