コード例 #1
0
    def MAJ(self, figure=None, DB=None, dictParametres={}):
        self.dictParametres = dictParametres
        # Création du graph
        ax = figure.add_subplot(111)

        dictResultats = GetComparatifNombre(DB, dictParametres)
        if dictResultats == None or len(dictResultats) == 0:
            return figure

        listeLabels = dictResultats["labels"]
        listeValeurs = dictResultats["valeurs"]
        indexPeriodeReference = dictResultats["indexPeriodeReference"]

        # Création du graph
        ind = arange(len(listeLabels)) + self.decalage_x
        width = 0.5
        for x in range(len(listeLabels)):
            if x == indexPeriodeReference:
                couleur = MODELES.ConvertitCouleur2(MODELES.COULEUR_VERT_POMME)
            else:
                couleur = MODELES.ConvertitCouleur2(MODELES.COULEUR_BLEU_CIEL)
            barre = ax.bar(ind[x], listeValeurs[x], width, color=couleur)

        # Axe horizontal
        ind = arange(len(listeLabels))
        ax.set_xticks(ind + width)
        ax.set_xticklabels(listeLabels)
        labelsx = ax.get_xticklabels()
        labelsy = ax.get_yticklabels()
        matplotlib.pyplot.setp(labelsx,
                               rotation=45,
                               fontsize=9,
                               horizontalalignment='right')

        # Axe vertical
        ax.set_ylabel("Nbre de familles", fontsize=8)

        labels = ax.get_yticklabels()
        matplotlib.pyplot.setp(labels, rotation=0, fontsize=9)

        # Titre
        title = ax.set_title(
            _(u"Comparatif du nombre de familles"),
            weight="bold",
            horizontalalignment='center')  #, position=(0.5, 0.97))
        matplotlib.pyplot.setp(title, rotation=0, fontsize=9)

        figure.subplots_adjust(left=None,
                               bottom=0.4,
                               right=None,
                               wspace=None,
                               hspace=None)

        # Affiche les grilles
        ax.grid(True, linestyle=":")

        return figure
コード例 #2
0
    def MAJ(self, figure=None, DB=None, dictParametres={}):
        self.dictParametres = dictParametres
        # Création du graph
        ax = figure.add_subplot(111)

        dictTranches = GetDictQuotients(DB,
                                        dictParametres)["dictTranchesDefaut"]

        listeValeurs = []
        listeLabels = []

        # Tri des tranches par ordre croissant
        listeTranches = list(dictTranches.keys())
        # listeTranches.sort()
        listeTranches = TrierQF(listeTranches)

        # Création du tableau des valeurs
        index = 1
        for tranche in listeTranches:
            valeur = dictTranches[tranche]
            if tranche == "autre":
                label = None
            elif tranche == "pasqf":
                label = None
            else:
                label = u"%d - %d" % tranche
            if label != None and valeur != 0:
                #if index % 2 == 0 : label = ""
                # Mémorisation des valeurs
                listeValeurs.append(valeur)
                listeLabels.append(label)
                index += 1

        # Création du graph
        ind = arange(len(listeLabels)) + self.decalage_x
        width = 0.5
        barres = ax.bar(ind,
                        listeValeurs,
                        width,
                        color=MODELES.ConvertitCouleur2(
                            MODELES.COULEUR_VERT_POMME))

        # Axe horizontal
        ax.set_xlabel(_(u"Tranches"), fontsize=8)
        ind = arange(len(listeLabels))
        ax.set_xticks(ind + width)
        ax.set_xticklabels(listeLabels)
        labelsx = ax.get_xticklabels()
        labelsy = ax.get_yticklabels()
        matplotlib.pyplot.setp(labelsx,
                               rotation=45,
                               fontsize=8,
                               horizontalalignment='right')

        # Axe vertical
        ax.set_ylabel("Nbre de familles", fontsize=8)
        labels = ax.get_yticklabels()
        matplotlib.pyplot.setp(labels, rotation=0, fontsize=9)

        # Titre
        title = ax.set_title(
            self.nom, weight="bold",
            horizontalalignment='center')  #, position=(0.5, 0.97))
        matplotlib.pyplot.setp(title, rotation=0, fontsize=9)

        figure.subplots_adjust(left=None,
                               bottom=0.28,
                               right=None,
                               wspace=None,
                               hspace=None)

        # Affiche les grilles
        ax.grid(True, linestyle=":")

        return figure