| 12
 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
 29
 30
 31
 32
 33
 34
 
 | 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
    cp = 1
    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)
        fig= plt.figure(1)
        ax1 = fig.add_subplot(sub)
        ax1.plot(x, y, label=key)
        if cp == 2:
            ax2 = fig.add_subplot(sub + 1, sharex=ax1)
            ax2.plot(x, y, label=key)
        if cp == 3:
            ax3 = fig.add_subplot(sub + 2, sharex=ax2)
            ax3.plot(x, y, label=key)
        #sub = sub + 1
        cp = cp + 1
        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