# Python 3.11 --  demo matplotlib using AGG backend showing in framebuffer
# Provided by Anthony Vogelaar, Perth Scotland
# rev 0.10  2024-04-30  initial release

import  os;                                 os.system('clear')
from    matplotlib.figure                   import  Figure
from    matplotlib.backends.backend_agg     import  FigureCanvasAgg

class Img():

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


    def show(self):
        canvas = FigureCanvasAgg(self.fig)      # Create a AntiGrain Geometry canvas
        canvas.print_png('temp.png')
        os.system("fbi temp.png")                # Show png file in frame buffer, run as root


img = Img()
img.show()
