jupyter中python循环语句中更新绘图 动图 gif
1 import matplotlib.pyplot as plt 2 from IPython.display import display, clear_output 3 4 lst=[] 5 fig,ax=plt.subplots() 6 for i in range(10): 7 ax.cla() 8 lst.append(i*i) 9 ax.plot(lst) 10 display(fig) 11 clear_output(wait=True) 12 plt.pause(0.1)