gcalderone / Gnuplot.jl

Julia interface to gnuplot
Other
119 stars 16 forks source link

save multiplots #4

Closed lazarusA closed 4 years ago

lazarusA commented 4 years ago

Hello, great package!

when I try to save a figure with multiple plots I get the error : You can't change the terminal in multiplot mode. The MWE could be the same as in the README.md file in your Gnuplot repository.

gcalderone commented 4 years ago

Thanks!

Could you please try the following code:

using Gnuplot
x = range(-2pi, stop=2pi, length=100);
y = 1.5 .* sin.(0.3 .+ 0.7x) ;
noise = randn(length(x))./2;
e = 0.5 * fill(1., length(x));
name = "\$MyDataSet1"
@gp x y+noise e name :-
@gp :- "f(x) = a * sin(b + c*x); a = 1; b = 1; c = 1;"  :-
@gp :- "fit f(x) $name u 1:2:3 via a, b, c;" :-
@gp :- "set multiplot layout 2,1" :-
@gp :- "plot $name w points tit 'Data'" ylab="Data and model" :-
@gp :- "plot $name u 1:(f(\$1)) w lines tit 'Best fit'" :-
@gp :- 2 xlab="X label" ylab="Residuals" :-
@gp :- "plot $name u 1:((f(\$1)-\$2) / \$3):(1) w errorbars notit"
save("output.gp")
save(term="png", output="output.png")

? Also, please report your version of Gnuplot.jl with:

using Pkg
Pkg.status("Gnuplot")
lazarusA commented 4 years ago

Ohh I see... my bad... I was using an extra :- at the end in the last @gp. I also noticed that the order of appearance for @gp :- "set multiplot layout 2,1" :- changes things, i.e., if one declares it first.

Everything works! Thanks!

By the way...

julia> using Pkg
julia> Pkg.status("Gnuplot")
    Status `~/.julia/environments/v1.3/Project.toml`
  [dc211083] Gnuplot v1.0.0