Gnuplot: how to plot into an existing figure?

Ok and sorry for the misunderstanding. Could you check if code below is what you need?

using Gnuplot

# This plotting is inside a function outputs to two windows:
function f()
	x = collect(-1:0.1:1)
	@gp :GP1
	@gp :- :GP1 x x.^2  "lw 2 lc rgb 'red' with lines title 'quadratic' " 
	@gp :GP2
	@gp :- :GP2 x x.^3  "lw 2 lc rgb 'green' with lines title 'cubic' " 
end

f()

x = collect(-1:0.1:1);
@gp :- :GP1 x x.^4  "lw 2 lc rgb 'blue' with lines title 'quartic on top of 1' " 
@gp :- :GP2 x x.^4  "lw 2 lc rgb 'blue' with lines title 'quartic on top of 2' " 
1 Like