add live plotting example

This commit is contained in:
acereca 2018-06-12 21:53:08 +02:00
parent 6fd8ff68cd
commit 95685bf4d5
1 changed files with 34 additions and 0 deletions

34
data/live.py Normal file
View File

@ -0,0 +1,34 @@
#!/usr/bin/env python
import numpy as np
import time
import matplotlib
#matplotlib.use('GTKAgg')
from matplotlib import pyplot as plt
plt.style.use('bmh')
plt.ion() ## Note this correction
fig=plt.figure()
i=0
x=list()
yd=list()
y=list()
while i <1000:
temp_y=np.loadtxt("/sys/class/thermal/thermal_zone0/temp")/1000
x.append(i);
y.append(temp_y);
try:
t = y[-1]
for deg in range(4):
t += yd[deg-1]
t /=2
yd.append(t)
except:
yd.append(temp_y)
plt.clf()
plt.plot(x,yd);
i+=1;
plt.xlim([i-500, i])
plt.show()
plt.pause(.05) #Note this correction