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