python画动态图(gif)
1.散点图gif
## 不加这行代码会导致无法显示
%matplotlib notebook
from matplotlib import pyplot as plt
import numpy as np
from matplotlib import animation
plt.rcParams['font.sans-serif'] = ['KaiTi']
plt.rcParams['axes.unicode_minus'] = False
fig = plt.figure(figsize = (14,6))
ax = fig.add_subplot(1, 2, 1)
ax1 = fig.add_subplot(1, 2, 2)
total = 40 ## 点总数,限于文件大小,只进行40次
# 产生数据
x, y = np.random.random((2, total))
z = (x**2 + y**2 >1)
# create the first plot
point, = ax.plot([], [] ,'r.')
point2, = ax.plot([], [] , 'b.'