本文整理汇总了Python中drawnow函数的典型用法代码示例。如果您正苦于以下问题:Python drawnow函数的具体用法?Python drawnow怎么用?Python drawnow使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了drawnow函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: update
def update(self, dThread):
mutex.acquire();
if len(dThread.dataArray)==0:
val = 0;
self.data.append(val);
self.time.append(0);
else:
val = dThread.dataArray[len(dThread.dataArray)-1];
self.data.append(val);
self.time.append(dThread.timeArray[len(dThread.timeArray)-1]);
mutex.release();
val_ = int(255*(val+2)/10);
print val_, val
if val_<0:
val_ = 0;
if val_ > 255:
val_ = 255;
#print "presenting %s" %(val_);
cv2.rectangle(self.bg,(100,100),(200,200),(val_,val_,val_),-1);
cv2.imshow("disp",self.bg);
if cv2.waitKey(10)==27:
return 0;
drawnow(self.makeFig);
plt.pause(0.00001);
if (len(self.data)>100):
self.data.pop(0);
self.time.pop(0);
return 1;
示例2: update
def update(self):
if len(globalDataValues)==0:
val = 0;
self.data.append(val);
self.time.append(0);
else:
val = globalDataValues[len(globalDataValues)-1];
self.data.append(val);
self.time.append(globalTimeValues[len(globalTimeValues)-1]);
val_ = int(255*(val)/100);
if val_<0:
val_ = 0;
if val_ > 255:
val_ = 255;
#print "presenting %s" %(val_);
cv2.rectangle(self.bg,(100,100),(200,200),(val_,val_,val_),-1);
cv2.imshow("disp",self.bg);
if cv2.waitKey(10)==27:
return 0;
drawnow(self.makeFig);
plt.pause(0.00001);
if (len(self.data)>100):
self.data.pop(0);
self.time.pop(0);
return 1;
示例3: main
def main():
global depth,time,presentime,pasttime,prev_val
rospy.init_node("depth_plot",anonymous=True)
match=plotty()
rate=rospy.Rate(100)
count=0
count1=0
while not rospy.is_shutdown():
#print match.depth
if match.depth >1300 or match.depth<960:
depth.append(prev_val)
else:
depth.append(float(match.depth))
prev_val=match.depth
time.append(count)
try:
drawnow(makefig)
except:
pass
plt.pause(0.00001)
count+=0.01
count1+=1
if count1>300 :
depth.pop(0)
time.pop(0)
示例4: main
def main():
inData = serial.Serial('/dev/ttyACM0')
plt.ion()
BMSArr = [0] * 9
sleep(0.2) # Wait a bit for serial connection to stabilise
while(1):
while (inData.inWaiting() == 0):
pass
dataLine = inData.readline()
dataArr = dataLine.split(",") # Read in and split on comma delimiters
if(len(dataArr) != 15): # Sanity check string
continue
# Sum the voltages from the inputs
vTotal = 0.0
try:
for i in range(1, 9):
vTotal += float(dataArr[i]);
vTotalArr.append(vTotal)
# Record and append timestamp
timestamp = float(dataArr[0])
print(dataLine)
timeArr.append(timestamp)
except:
pass
# Plot the figure and wait a tiny bit to stop drawnow crashing
drawnow(drawFig)
plt.pause(0.000001)
if(float(timestamp - timeArr[0]) >= 15000): # 15 seconds max on the graph at once
timeArr.pop(0)
vTotalArr.pop(0)
示例5: plotGraph
def plotGraph():
while True:
out=q.get()
data = [float(val) for val in out.split()]
if data:
count=0
while count<len(data):
cpuLoad.append(data[count])
count=count+1
drawnow(makefig)
示例6: tread
def tread(soc,event):
while True:
event.wait()
#print 'event.wait()'
event.clear()
#print soc
#print pltADC
#print ADC1
drawnow(makeFig) #Call drawnow to update our live graph
plt.pause(.000001) #Pause Briefly. Important to keep drawnow from crashing
示例7: main
def main():
with serial.Serial() as ser:
ser.baudrate = 9600
ser.port = arduino_serial_port()
ser.open()
while True:
data = waitForDataFromArduino(ser)
current_temp_contact = float( data[0] )
current_temp_ambient = float( data[1] )
current_pwm = float( data[2] )
temp_contact.append(current_temp_contact)
temp_ambient.append(current_temp_ambient)
#pwm.append(current_pwm)
delta = current_temp_contact - current_temp_ambient
print "pwm:{0} ambient:{1} contact:{2} delta:{3}".format(current_pwm, current_temp_ambient, current_temp_contact, delta)
drawnow(figure)
plt.pause(.000001)
++count
if(count>50):
temp_contact.pop(0)
temp_ambient.pop(0)
示例8: main
def main():
global yaw, time
rospy.init_node("yaw_plot",anonymous=True)
match=plotty()
rate=rospy.Rate(10)
count=0
count1=0
while not rospy.is_shutdown():
yaw.append(float(match.yaw))
time.append(count)
try:
drawnow(makefig)
except:
pass
plt.pause(0.00001)
count+=0.1
count1+=1
if count1>300 :
yaw.pop(0)
time.pop(0)
print count1
rate.sleep()
示例9: plot
def plot(self): # PROBLEMATICNA FUNKCIJA
global values
def plotValues():
plt.title('Trenutna Temperatura')
plt.grid(True)
plt.ylim(25, 35)
plt.ylabel('Temperatura [C]')
plt.xlabel('Vreme [s/2]')
plt.plot(values)
def doAtExit():
serialArduino.close()
atexit.register(doAtExit)
for i in range(0,1):
values.append(0)
while bulova == True:
if (serialArduino.inWaiting()>0):
pass
valueRead = serialArduino.readline()
try:
valueInFloat=float(valueRead)
if valueInFloat <= 1024.0:
if valueInFloat >= 0.0:
values.append(valueInFloat)
drawnow(plotValues)
#plt.pause(0.005)
else:
print("Invalid! negative number")
else:
print("Invalid! too large")
except ValueError:
pass
self.draw()
开发者ID:Milutin-P,项目名称:Breathing-Analysis-Python-Arduino-Integration,代码行数:36,代码来源:breath_analysis_python.py
示例10: getAverageAccel
return_array.append(count)
else:
return_array.append(count)
count = count + 1
return return_array
#Main Functions
try:
avg, maxThresh, minThresh = getAverageAccel()
fig_count = 0
while True:
time.sleep(1)
time2,paccZ = dataPull() #get data from log file
accel_Time.extend(time2)
accZ.extend(paccZ)
drawnow(finalDemo)
fig_count = fig_count + 1
if (fig_count == 10):
for x in xrange(3):
avg = np.mean(accZ)
accZ = accZ - avg
plot_time = accel_Time
plot_raw = accZ
#clip the values that are too high or low
#low_values_indices = clipping_data < minThresh
#clipping_data[low_values_indices] = minThresh
示例11: dataPull
if (lastAverageBPM >2+averageBPM):
print "Exacerbation risk is high"
print bpm[-2:]
print lastAverageBPM
print averageBPM
#######################################################################
#Main Functions
try:
while True:
time.sleep(10)
time2,paccZ = dataPull()
W_z, ffTtime_z, cut_signal_z, cut_f_signal_z, f_signal_z = ourFFT(paccZ,time2) #variables from Ravi
peakaccZ = detect_peaks(cut_signal_z)
breaths = len(peakaccZ)
drawnow(demoFig6)
drawnow(demoFig1)
bpm.append(breaths)
if (len(bpm)>2*bpmcount):
checkAverageBPM(bpm)
print(bpm)
bpmcount = bpmcount+1
except KeyboardInterrupt:
pass
with open(savepath+file_name+'.csv', 'wb') as csvfile:
print 'Saving Data...'
datacnt = 0
while(datacnt<len(W)):
dataWriter = csv.writer(csvfile)
示例12: dataPlot
updownA=[]
ser = serial.Serial('/dev/ttyACM0', 115200, timeout=2, xonxoff=False, rtscts=False, dsrdtr=False)
ser.flushInput()
ser.flushOutput()
plt.ion()
def dataPlot():
plt.title("X-Y Co-ordinate data from Joystick")
plt.grid(True)
plt.ylabel("ASCII Values")
plt.plot(leftrightA, 'ro-', label="ASCII")
plt.legend(loc='upper left')
plt2=plt.twinx()
plt2.plot(updownA)
while True:
while (ser.inWaiting()==0):
pass
dataStream = ser.readline();
#ser.read(dataStream)
#print dataStream
dataArray = dataStream.split(',')
#print dataArray[0]
#print dataArray[1]
leftright = float ( dataArray[0] )
updown = float( dataArray[1] )
#print leftright,",",updown
leftrightA.append(leftright)
updownA.append(updown)
drawnow(dataPlot)
示例13: initializeCompFilter
##filtering
if(t>captureTime*timecount):
if (timecount == 1):
my_x_comp_filter, my_y_comp_filter, accXavg, accYavg, accZavg, gyrXavg, gyrYavg, gyrZavg = initializeCompFilter(time,accX,accY,accZ,gyrX,gyrY,gyrZ)
print "Intialization complete"
accX = []
accY = []
accZ = []
gyrX = []
gyrY = []
gyrZ = []
if (timecount > 1):
filteredX, filteredY = compFilter(my_x_comp_filter, my_y_comp_filter,time,accX,accY,accZ,gyrX,gyrY,gyrZ,gyrXavg, gyrYavg, gyrZavg)
drawnow(makeFigRaw)
accX = []
accY = []
accZ = []
gyrX = []
gyrY = []
gyrZ = []
#freqX, fftX, fftY = ourFFT(filteredX,filteredY,time2)
W, ffTtime, cut_signal, cut_f_signal, f_signal = ourFFT2(filteredX,time2)
peakX = detect_peaks(cut_signal)
print peakX
drawnow(makeFig)
drawnow(makeSignalFig)
drawnow(makeFftFig)
#peakY = detect_peaks(filteredY)
#if (len(peakX)>=1 & len(peakY)>=1):
示例14: while
x1,y1=m(x,y)
xarray.append(x1)
yarray.append(y1)
m.drawcoastlines()
im = plt.imread("map.png")
m.imshow(im, origin='upper')
m.scatter(xarray,yarray,c='b',marker=".",alpha=1.0)
while(1):
#X AND Y ARE THE RECEIVED DATA FROM THE GPS SENSOR
#for now they have just been set to random numbers between the limits
pos = open(const_pos_sharefile,'r')
last_line = pos.readline()
while(last_line!=""):
x = float(last_line.split(",")[0])
print x
print 'Y:'
y = float(last_line.split(",")[1])
print y
print '-----'
last_line = pos.readline()
drawnow(makeFigs)
time.sleep(0.1)
#SYSTEM TO START DUMPING OLD DATA - might be completely useless?
threshold = 30 #maximum pieces of data
if len(xarray) > threshold:
xarray.pop(0)
yarray.pop(0)
示例15: print
print("D5 : ", D5)
print("D6 : ", D6)
print("D7 : ", D7)
print("D8 : ", D8)
# Her zaman dizide 25 karakter kalması için ilk dizi değeri silinir daha sonrasında append ile yeni değer aktarılır.
values_Distance.pop(0)
values_firstPath.pop(0)
values_firstPathAmp1.pop(0)
values_firstPathAmp2.pop(0)
values_firstPathAmp3.pop(0)
values_maxGrowthCIR.pop(0)
values_rxPreamCount.pop(0)
values_maxNoise.pop(0)
values_stdNoise.pop(0)
values_Distance.append(D0)
values_firstPath.append(D1)
values_firstPathAmp1.append(D2)
values_firstPathAmp2.append(D3)
values_firstPathAmp3.append(D4)
values_maxGrowthCIR.append(D5)
values_rxPreamCount.append(D6)
values_maxNoise.append(D7)
values_stdNoise.append(D8)
time.pop(0)
time.append(datetime.datetime.now())
drawnow(plotValues)