I am having 7 sensors which is connected to a micro controller , the controller a sends data to a pc using serial port , i am trying to plot the sensors values in real-time using python drawnow function , can anybody help me in giving the correct syntax for the same to plot the all the sensors in the same figure
Asked
Active
Viewed 1,618 times
1 Answers
0
How about this for 4 sensors:
import time
import matplotlib.pyplot as plt
from drawnow import *
sensors = 4
x = dict([(s,[]) for s in range(0,sensors)]) # initialize dictionary of sensor stream values
def makePlot():
plt.subplot(411)
plt.plot(x[0],'r')
plt.subplot(412)
plt.plot(x[1],'g')
plt.subplot(413)
plt.plot(x[2],'b')
plt.subplot(414)
plt.plot(x[3],'c')
for i in range(0,100): # simulate passage of time
time.sleep(1) # 1-sec delay for each loop
for s in range(0,sensors):
x[s].append(i*s)
drawnow(makePlot)

racket99
- 635
- 8
- 17