import numpy as np
import matplotlib.pyplot as plt
from matplotlib import animation
fig = plt.figure(figsize=(6,6), facecolor='white')
ax = fig.add_axes([0, 0, 1, 1], frameon=False, aspect=1)
size=np.random.rand(1)
scat = ax.scatter(10, 10, s=size)
def update(i):
global size
size=size*1.01
scat.set_sizes(size)
return scat,
anim = animation.FuncAnimation(fig, update, interval=30, blit=True)
plt.show()
散点动态图,一个变大的圆,注意size的数据类型是NP的数组!用普通的int类型是无效的!