问题描述
因此,在matplotlib.animation的例子有,用于使动画两个主要功能:AritstAnimation和FuncAnimation。
So in the examples of matplotlib.animation there are two main functions that are used to make animations: AritstAnimation and FuncAnimation.
根据文档中使用他们每个人是:
According to the documentation the use of each of them is:
.ArtistAnimation
在调用这个函数之前,所有的绘图应该采取地方及有关艺术家保存。
Before calling this function, all plotting should have taken place and the relevant artists saved.
FuncAnimation
通过反复调用一个函数func,传递(可选)论点fargs做动画。
FuncAnimationMakes an animation by repeatedly calling a function func, passing in (optional) arguments in fargs.
所以,在我看来,当你已经整个数组,列表或设置你想从动画任何对象,它ArtistAnimation是有益的。 FuncAnimation在另一方面,似乎只要你有一个功能,能够给它下一个结果更加有用。
So it appears to me that ArtistAnimation is useful when you have already the whole array, list or set of whatever object you want to make an animation from. FuncAnimation in the other hand seems to be more useful whenever you have a function that is able to give it your next result.
是我的直觉正确以上这件事?我一般的问题是更方便地使用一种或另一种的时候。
Is my intuition above correct about this? My question in general is when is more convenient to use one or the other.
在此先感谢
推荐答案
我认为你是正确的,虽然是简单的从列表中去功能(只是遍历的话)或向后(存储功能数组中的值)。
I think you are right, although it is simple to go from a list to a function (just iterate over it) or back (store function values in an array).
因此,它确实没有太大的关系,但是你可以选择最适合您的code的人,像你描述。
So it really doesn't matter too much, but you can pick the one that best suits your code, as you described.
(我个人觉得ArtistAnimation是最方便)
(Personally I find ArtistAnimation to be the most convenient)
如果你的结果是非常大的,它可能是很好用FuncAnimation,所以你不需要存储你的数据。 MPL仍然保存它自己的拷贝密谋,但这个因素男会有所作为。
If your result is very large, it might be good to use FuncAnimation so you don't need to store your data. MPL still stores it's own copy for plotting, but this factor two might make a difference.
这篇关于ArtistAnimation VS FuncAnimation matplotlib动画matplotlib.animation的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!