import numpy as npfrom matplotlib import pyplot as pltfrom matplotlib import animation# first set up the figure, the axis, and the plot element we want to animatefig = plt.figure()ax1 = fig.add_subplot(3, 1, 1, xlim=(0, 2), ylim=(-4, 4))ax2 = fig.add_subplot(3, 1, 2, xlim=(0, 2), ylim=(-4, 4))ax3 = fig.add_subplot(3, 1, 3, xlim=(0, 2), ylim=(-4, 4))line, = ax1.plot([], [], lw=2)line2, = ax2.plot([], [], lw=2)line3, = ax3.plot([], [], lw=2)def init():
	line.set_data([], [])
	line2.set_data([], [])
	line3.set_data([], [])
	return line, line2,line3# animation function.  this is called sequentiallydef animate(i):
	x = np.linspace(0, 2, 100)
	y = np.sin(2 * np.pi * (x - 0.01 * i))
	line.set_data(x, y)

	x2 = np.linspace(0, 2, 100)
	y2 = np.cos(2 * np.pi * (x2 - 0.01 * i)) * np.sin(2 * np.pi * (x - 0.01 * i))
	line2.set_data(x2, y2)

	x3 = np.linspace(0, 2, 100)
	y3 = np.cos(2 * np.pi * (x3 - 0.01 * i)) * np.sin(2 * np.pi * (x - 0.01 * i))
	line3.set_data(x3, y3)
	return line, line2if __name__ == '__main__':


	anim1 = animation.FuncAnimation(fig, animate, init_func=init, frames=50, interval=10)
	plt.show()

import numpy as npfrom matplotlib import pyplot as pltfrom matplotlib import animation# first set up the figure, the axis, and the plot element we want to animatefig = plt.figure()ax_list=[]for ax_one in range(20):
	ax1 = fig.add_subplot(4,5,ax_one+1, xlim=(0, 2), ylim=(-4, 4))
	line, = ax1.plot([], [], lw=2)
	ax_list.append((ax1,line))def init():
	line_list=[]
	for one_line in ax_list:
		one_line[1].set_data([], [])
		line_list.append(one_line[1])
	return tuple(line_list)# animation function.  this is called sequentiallydef animate(i):

	x = np.linspace(0, 2, 100)
	y = np.sin(2 * np.pi * (x - 0.01 * i))
	line_list = []
	for one_line in ax_list:
		one_line[1].set_data(x, y)
		line_list.append(one_line[1])
	return tuple(line_list)if __name__ == '__main__':

	anim1 = animation.FuncAnimation(fig, animate, init_func=init, frames=50, interval=10)
	plt.show()

from matplotlib import pyplot as pltfrom matplotlib import animationimport matplotlib.font_manager as fm
fig = plt.figure()ax_list=[]for ax_one in range(3):
	ax1 = fig.add_subplot(3,1,ax_one+1, ylim=(0,100))
	ax1.spines['top'].set_color('none')
	ax1.spines['right'].set_color('none')
	myfont = fm.FontProperties(fname=r'/home/chenyang/PycharmProjects/show_face_decetor/fonts/simsun.ttf')
	name_list = ['Sur', "Fea", "Dis", "Hap", "Sad", "Ang", "Nat", "x", "y", "z"]
	index = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
	index = [float(c) for c in index]
	plt.ylim(ymax=110, ymin=0)
	plt.xticks(index, name_list, rotation=20, fontsize=10)
	plt.ylabel("lsd", fontproperties=myfont, fontsize=20)
	ax_list.append(ax1)def init():
	line_list=[]
	for one_line in ax_list:
		line_list.append(one_line)
	return tuple(line_list)# animation function.  this is called sequentiallydef animate(i):

	line_list = []
	for ax_one in ax_list:
		plt.ylabel(str(i), fontproperties=myfont, fontsize=20)

		line_list.append(ax_one.bar(range(len(name_list)),[i,23,23,23,4,34,3,34,3,23], color='bgr'))
	return tuple(line_list)if __name__ == '__main__':

	anim1 = animation.FuncAnimation(fig, animate, init_func=init, frames=100, interval=10)
	plt.show()

from matplotlib import pyplot as pltfrom matplotlib import animationimport random# first set up the figure, the axis, and the plot element we want to animatefig = plt.figure()ax_list=[]for ax_one in range(20):
	ax1 = fig.add_subplot(4,5,ax_one+1, xlim=(0, 9), ylim=(0, 100))
	line, = ax1.plot([], [], lw=2)
	ax_list.append((ax1,line))def init():
	line_list=[]
	for one_line in ax_list:
		one_line[1].set_data([], [])
		line_list.append(one_line[1])
	return tuple(line_list)# animation function.  this is called sequentiallyl_=[]for _ in range(1000):
	x=[]
	for _ in range(10):
		x.append(random.randrange(100))
	l_.append(x)def animate(i):
	x = [range(10)]
	y = l_.pop(0)
	line_list = []

	for one_line in ax_list:
		one_line[1].set_data(x, y)
		line_list.append(one_line[1])

	return tuple(line_list)if __name__ == '__main__':

	anim1 = animation.FuncAnimation(fig, animate, init_func=init, frames=100000, interval=10)
	plt.show()

matpoltlib 动态画图_matpoltlib