我想在下面运行这段代码,但它不能正常工作。我遵循matplotlib的文档,并想知道下面这个简单的代码有什么问题。我正在尝试使用anaconda发行版将它制作成jupyter笔记本。我的Python版本是2.7.10。简单的Matplotlib动画不起作用
import numpy as np
from matplotlib import pyplot as plt
from matplotlib import animation
fig = plt.figure()
def init():
m = np.zeros(4800)
m[0] = 1.6
return m
def animate(i):
for a in range(1,4800):
m[a] = 1.6
m[a-1] = 0
return m
anim = animation.FuncAnimation(fig, animate, init_func=init,
frames=200, interval=20, blit=True)
plt.show()
你能解释一下什么是不工作?你得到了什么,你期望什么?你的代码的一个问题当然是你没有绘制任何东西。你看过matplotlib动画例子吗? –
我在这里尝试的是获取值1.6并将其移动到每个交互的右侧。因此,例如在时间t = 1时,我想有[1.6,0,0,0,0],在时间t = 2 [0,1.6,0,0,0]等上。我已经看过这些例子,但是所有这些看起来都很复杂,因为我在这里寻找的是简单的东西。我清楚了吗? – Mensch