Bonjour,

Je suis un petit projet pour afficher des données sur graphe avec matplotlib, jusqu'à la tout marche à merveille.
Mon projet est dessiné avec Qt Designer PyQt5.
A l'exécution du programme le graphe est affiché dans une fenêtre de matplotlib.

Mon souhait est d'afficher le graphe dans un QWidget que j'ai déjà ajouté dans ma fenêtre principale, j'ai beau cherché mais en vain.

Ci-dessous un bout du code pour la création du graph

Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
 
        self.figure = Figure()
        self.canvas = FigureCanvasQTAgg(self.figure)
        self.figure.clf()
        self.canvas.figure = plt.figure(figsize=(8, 5))
 
        ax1 = self.canvas.figure.add_subplot(111)
        ax2 = self.canvas.figure.add_subplot(111)
        ax3 = self.canvas.figure.add_subplot(111)
 
        ax1.set_title ("Phases")
        ax1.set_xlabel ('Date')
        ax1.set_ylabel ("Valeur ")
 
        ax1.plot_date (date, phase1, '-', label="Phase1", color='r', linewidth=1, marker='^')
        ax2.plot_date (date, phase2, '-', label="Phase2", color='g', linewidth=1, marker='o')
        ax3.plot_date (date, phase3, '-', label="Phase3", color='b', linewidth=1, marker='x')
 
        self.canvas.figure.autofmt_xdate (rotation=45)
        self.canvas.figure.tight_layout()
 
        ax1.grid (True)
        ax1.legend (loc='best', framealpha=0.5)
 
        # plt.savefig ("courbe.png")
        plt.show()
Merci.