小编inv*_*ble的帖子

如何在 matplotlib 中停止动画?

所以我是Python新手,一直在尝试用matplotlib中的动画来模拟地球和月球的运动,动画效果很好,但它永远不会真正结束,有没有一种简单的方法可以做到这一点?代码如下:

def animate(i):
    orbits()
    ax1.clear()
    plt.axis('equal')
    ax1.plot(xMlist, yMlist)
    ax2.plot(xElist, yElist)

ani = animation.FuncAnimation(fig, animate,frames=10, interval=1)
plt.show()  
Run Code Online (Sandbox Code Playgroud)

就像我说的,我对Python相对陌生,所以如果这是一个简单的答案,我真的很抱歉,但我到处都看了,尝试过的方法似乎都不起作用,例如设置帧数并没有改变任何东西,所以我真的很茫然。

python animation matplotlib

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

标签 统计

animation ×1

matplotlib ×1

python ×1