मैं एक थ्रेड में एक सॉकेट से डेटा पढ़ रहा हूं और साजिश को प्लॉट करना और अपडेट करना चाहता हूं क्योंकि नया डेटा आता है। मैं एक छोटे से प्रोटोटाइप अप कोडित बातें अनुकरण करने के लिए, लेकिन यह काम नहीं करता है:क्या आप matplotlib में लाइव डेटा प्लॉट कर सकते हैं?
import pylab
import time
import threading
import random
data = []
# 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()
pylab.figure()
while True:
time.sleep(1)
pylab.plot(data)
pylab.show() # This blocks :(
http://stackoverflow.com/questions/14665636/time-sleep-required-to-keep-qthread-responsive – tacaswell
http://stackoverflow.com/questions/8955869/why-is-plotting-with-matplotlib -सो-धीमी/8956211 # 8956211 – tacaswell
http://stackoverflow.com/questions/11874767/real-time-plotting-in-while-loop-with-matplotlib/15724978#15724978 – tacaswell