python animation函数解析,python中的函数怎么使用

首页 > 娱乐 > 作者:YD1662025-07-12 04:02:54

python animation函数解析,python中的函数怎么使用(1)

代码示例:

import matplotlib.pyplot as plt

import numpy as np

from matplotlib import animation

fig, ax = plt.subplots()

x = np.arange(0, 2 * np.pi, 0.01)

line, = ax.plot(x, np.sin(x))

def animate(i):

line.set_ydata(np.sin(x + i / 100))

return line,

def init():

line.set_ydata(np.sin(x))

return line,

ani = animation.FuncAnimation(fig=fig, func=animate, frames=100,

init_func=init, interval=20, blit=False)

plt.show()

栏目热文

文档排行

本站推荐

Copyright © 2018 - 2021 www.yd166.com., All Rights Reserved.