积跬步致千里 || 可视化动图展示

可视化动图展示

目前只能在 jupyter notebook 中测试成功

%matplotlib notebook
import numpy as np
import matplotlib.pyplot as plt
import time

n = 500
data = np.random.normal(0,1,n)

fig = plt.figure()
ax = fig.add_subplot(111)

fig.show()
fig.canvas.draw()

for i in range(0,100):
    ax.clear()
    ax.plot(data[0:i]),ax.axis([-1,110,-3,3])
    fig.canvas.draw()
    time.sleep(0.1)

积跬步致千里 || 可视化动图展示_第1张图片

%matplotlib notebook
import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns
import time

n = 200

fig = plt.figure()
ax = fig.add_subplot(111)

fig.show()
fig.canvas.draw()

for i in range(0,100):
    ax.clear()
    mat = np.random.rand(n,n)
    ax.matshow(mat)
    fig.canvas.draw()
    time.sleep(0.1)

积跬步致千里 || 可视化动图展示_第2张图片

你可能感兴趣的:(积跬步至千里,算法)