Python matplotlib.pyplot dynamic graph refresh real-time refresh real-time drawing in the same window

Code

import matplotlib.pyplot as plt
i=0
x=[]
y=[]
while i<100000:
    plt.clf()  #清除上一幅图像
    x.append(i)
    y.append(i**2)
    plt.plot(x,y)
    i=i+1
    plt.pause(0.01)  # 暂停0.01秒
    plt.ioff()  # 关闭画图的窗口

Insert picture description here

Guess you like

Origin blog.csdn.net/qq_43511299/article/details/113781883