Creating a Grafica plot in Pgraphics or new window

Hi all,

I would like to make a Grafica plot in a Pgraphics but soon realised that it is not possible in my case. So I followed the workaround suggested by @GoToLoop on: https://discourse.processing.org/t/plot-grafica-in-pgraphics/2334 and make the plot in a new window.

The example works, but now I try to implement the same functionality in my program and I get the following error:

window.pde:87:0:87:0: RuntimeException: createGraphics() with P2D requires size() to use P2D or P3D

The error is caused by these lines in the class of GoToLoop:

void settings() {
    size(450, 450);
  }

Removing this block of code or adding P2D to the size does not work.

I know this might be a vague question, but does anyone know how I can solve this problem?

Kind regards,
Thomas