# Python 3.11 --  demo matplotlib using AGG backend
# Provided by Anthony Vogelaar, Perth Scotland
# rev 0.10  2024-04-29  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])
        print('fig:', self.fig)
        print('ax :', ax)


    def save(self, fn):
        canvas = FigureCanvasAgg(self.fig)      # Create a AntiGrain Geometry canvas
        canvas.print_png(fn)
        # self.fig.savefig(f'i_{fn}')


img = Img()
img.save('img.png')
