FuncAnimation类
class matplotlib.animation.FuncAnimation(
fig, func, frames=None, init_func=None,
fargs=None, save_count=None, **kwargs)
参数
fig : matplotlib.figure.Figure对象,可以理解为画布
func : 函数(callable),每一帧被调用一次
函数签名大概是这样的:def func(frame, *fargs) -> iterable_of_artists
第一个参数是frames中的元素,第二个是fargs参数设置的附件参数
返回值是可迭代的图形对象
frames : 可迭代对象, 整数, 生成函数或者None,传递给动画函数func的帧
如果是可迭代对象,可迭代对象的长度将覆盖save_count参数
如果是个整数,值就是range(frames)
如果是生成函数,签名必须是def gen_function() -> obj:
如果是None,frames=itertools.count,相当于整数从0开始步长1无限迭代
init_func : 函数(callable)
用来画一个完整的帧,如果没有给,使用的是frames中的第一个元素,在第一帧之前被调用
如果If blit == True, init_func 必须返回一个可迭代的图形对象 签名像:def init_func() -> iterable_of_artists:
fargs : 元组或None,每一次调用func的附加参数
save_count : 整数,缓存的帧的数量
interval : number, 2帧之间的延迟,默认200毫秒
repeat_delay : number, 重复延迟,默认None
repeat : bool, 是否重复,默认True
blit : bool, 是否使用blitting优化,默认False
blitting的含义是内存中图像的位块传输,指的是将某一表面的全部或部分图像复制到另一表面上
动图存储配置
# print matplotlib.matplotlib_fname()
# matplotlib\mpl-data\matplotlibrc
animation.writer : ffmpeg ## MovieWriter 使用
animation.ffmpeg_path: ffmpeg ## 可执行文件ffmpeg路径,会搜索$PATH
animation.convert_path: magick ## 可执行文件magick路径,会搜索$PATH
animation.convert_args: convert