See e.g. https://lazy-fortran.github.io/fortplot/page/examples/basic_plots.html . Maybe you were too eager when implementing the figure CLEAR logics.