Python matplotlib.pyplot动态图刷新实时刷新在同一窗口中实时画图

代码

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()  # 关闭画图的窗口

在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/qq_43511299/article/details/113781883