相关疑难解决方法(0)

在matplotlib中使用for循环定义要绘制动画的多个绘图

感谢Jake Vanderplas,我知道如何开始编写动画情节matplotlib.这是一个示例代码:

from matplotlib import pyplot as plt
from matplotlib import animation

fig = plt.figure()

ax = plt.axes(xlim=(0, 2), ylim=(0, 100))

line, = plt.plot([], [])

def init():
    line.set_data([], [])
    return line,

def animate(i):
    line.set_data([0, 2], [0,i])
    return line,

anim = animation.FuncAnimation(fig, animate, init_func=init,
                               frames=100, interval=20, blit=True)

plt.show()
Run Code Online (Sandbox Code Playgroud)

假设现在我想在循环的帮助下绘制大量函数(比如说四个).我做了一些伏都教程序,试图理解如何模仿下面的逗号,这就是我得到的(不用说它不起作用:) AttributeError: 'tuple' object has no attribute 'axes'.

from matplotlib import pyplot as plt
from matplotlib import animation

fig = plt.figure()

ax = plt.axes(xlim=(0, 2), ylim=(0, 100))

line = …
Run Code Online (Sandbox Code Playgroud)

python animation matplotlib

8
推荐指数
1
解决办法
2万
查看次数

标签 统计

animation ×1

matplotlib ×1

python ×1