import matplotlib.pyplot as pltimport timeimport threadingimport randomdata = []# This just simulates reading from a socket.def data_listener(): while True: time.sleep(1) data.append(random.random())if __name__ == '__main__': thread = threading.Thread(target=data_listener) thread.daemon = True thread.start() # # initialize figure plt.figure() ln, = plt.plot([]) plt.ion() plt.show() while True: plt.pause(1) ln.set_xdata(range(len(data))) ln.set_ydata(data) plt.draw()
如果您想走得很快,则应考虑发li。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)