Of course it works well in Linux, except when I build the app as an appImage. I think it is a PATH issue (looking in the /usr/bin of the bundle??) but I don’t know how I can solve it.
What is the correct way to do it?
Where is that gnuplot located? Inside or outside the AppImage? Since gnuplot cannot be expected to come with all Linux distributions by default, you should bundle it (and its dependencies) inside your AppImage.
You need to put it onto the $PATH so that your code works.
Or change the code to check for <location from which the current application is running>/gnuplot.