# Python 3.11 --  demo matplotlib using Qt backend
# Provided by Anthony Vogelaar, Perth Scotland
# rev 0.10  2024-04-29  initial release

from    matplotlib.figure                   import  Figure
from    matplotlib.backends.backend_qtagg   import  FigureCanvasQTAgg, NavigationToolbar2QT
from    PySide6.QtWidgets                   import  QApplication, QWidget, QVBoxLayout

class GUI(QWidget):

    def __init__(self):
        super().__init__()
        layout = QVBoxLayout(self)

        fig    = Figure(figsize=(5, 4))
        ax     = fig.add_subplot()
        ax.plot([1, 2.5, 3, 4], [1, 4, 2, 3])

        canvas = FigureCanvasQTAgg(fig)                 # Create a Qt compatible canvas
        layout.addWidget(canvas)                        # Embed the canvas in Qt

        layout.addWidget(NavigationToolbar2QT(canvas))      
        self.show()


app = QApplication()
gui = GUI()
app.exec()
