|
From: Gökhan S. <gok...@gm...> - 2010-03-12 20:36:22
|
Hello,
I read a simple data stream from my computers serial port. I can nicely read
the data using pyserial library but couldn't get it *nicely* working neither
with WXAgg nor Qt4Agg using the following code. Although with WX I could get
updated looks, the figure isn't very responsive in this way. I have looked
at simple_idle_wx example but for some reason I can't make it work to update
the canvas whenever the condition satisfied.
What is the trick to make the real-time data plotted on the screen easily
without blocking the figure itself?
import serial
import matplotlib.pyplot as plt
plt.ion()
ser = serial.Serial(0)
conc = []
while True:
s = ser.readline()
if s.startswith('CONC'):
conc.append(float(s.split()[2]))
plt.plot(conc)
plt.show()
plt.clf()
ser.close()
--
Gökhan
|