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

from    matplotlib.figure                   import  Figure
from    matplotlib.backends.backend_tkagg   import  FigureCanvasTkAgg, NavigationToolbar2Tk
from    tkinter                             import  Tk, mainloop

class GUI(Tk):

    def __init__(self):
        super().__init__()

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

        canvas = FigureCanvasTkAgg(fig)             # Create a TkInter compatible canvas
        canvas.get_tk_widget().pack()               # Embed the canvas in TkInter

        NavigationToolbar2Tk(canvas, self, pack_toolbar=False).pack()
        canvas.draw()


gui = GUI()
mainloop()
