Graphique d'évolution de températures
Bonjour à tous,
Ayant un peu de temps dans mon boulot, j'ai voulu m'essayer au Python.
Mais je reste bloqué sur un problème très bête...
J'utilise matplotlib et "gobject.timeout_add(10000, coroutine().next)" pour faire un maj toutes les 10s
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
| import matplotlib.pyplot as plt
def coroutine():
nbplot=5
x = linspace(0, -50, nbplot+1)
HK= []
index=0
HK.append(ctrl.GetHK())
fig = plt.figure(1, (10., 10.))
while(1):
HK.append(ctrl.GetHK())
if(index<nbplot):
index+=1
else:
HK.pop(0)
print(HK[index])
fig.clear()
fig.add_subplot(111)
for i in range(size(HK,1)):
plt.plot(x[:index+1], asarray(HK)[:,i], label='r' + repr(i) + ' ' + repr(HK[index][i]))
plt.legend()
plt.axis('tight')
plt.show()
yield True |
La fonction ctrl.GetHK() retourne un tableau de 4 float
Donc la première se passe bien mais il n'y a pas de mise à jour...
Pouvez éclairer mon problème ? Car je tourne en rond, actuellement....