动图显示animation

动图显示

import matplotlib.pyplot as plt
import numpy as np
from matplotlib import animation
import threading 

def animate(i):
    line.set_ydata(np.sin(x + i / 10))

def init():
    line.set_ydata(np.sin(x))
    return line,
fig, ax = plt.subplots()

x = np.arange(0, 20, 0.1)
line, = ax.plot(x, np.sin(x))
ani = animation.FuncAnimation(fig=fig, func=animate, frames=None,
						  init_func=init, blit=False)
plt.show()

你可能感兴趣的:(python)