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
|
def plotting_dico(dico, titre):
"""
Plot a partir des data contenus dans dico
"""
x = []
y = []
nbMesures = len(dico.keys())
sub = 11 + nbMesures*100 # nbre de subplots
for key in sorted(dico.iterkeys()):
points = [(datetime.strptime(i[0], "%d/%m/%y-%H:%M:%S"), \
i[1]) for i in dico[key]]
points.sort()
x, y = zip(*points)
plt.figure(1)
plt.subplot(sub)
sub = sub + 1
plt.plot(x, y, label=key)
formatter = DateFormatter('%Y-%m-%d %H:%M:%S')
plt.gcf().axes[0].xaxis.set_major_formatter(formatter)
plt.gcf().autofmt_xdate()
plt.legend(loc='upper right')
plt.xlabel('Dates (GMT)')
plt.ylabel(titre)
plt.grid(True)
plt.show()
return |
Partager