jupyter中python循环语句中更新绘图

import matplotlib.pyplot as plt
from IPython.display import display, clear_output

lst=[]
fig,ax=plt.subplots()
for i in range(10):
    ax.cla()
    lst.append(i*i)
    ax.plot(lst)
    display(fig)
    clear_output(wait=True)
    plt.pause(0.1)

参考:

Matplotlib Update Plot In Loop - Python Guides

你可能感兴趣的:(python,jupyter,matplotlib)