Python 2.7 在python中使用drawnow绘制多个传感器值
我有7个传感器连接到一个微控制器,控制器a使用串行端口向pc发送数据,我尝试使用python drawnow函数实时绘制传感器值,有没有人能帮我给出正确的语法,以便在同一个图中绘制所有传感器的图呢Python 2.7 在python中使用drawnow绘制多个传感器值,python-2.7,drawnow,Python 2.7,Drawnow,我有7个传感器连接到一个微控制器,控制器a使用串行端口向pc发送数据,我尝试使用python drawnow函数实时绘制传感器值,有没有人能帮我给出正确的语法,以便在同一个图中绘制所有传感器的图呢 import time import matplotlib.pyplot as plt from drawnow import * sensors = 4 x = dict([(s,[]) for s in range(0,sensors)]) # initialize dictionary o
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)