diff --git a/src/Gnuplot.jl b/src/Gnuplot.jl index 61e1837..ba91697 100644 --- a/src/Gnuplot.jl +++ b/src/Gnuplot.jl @@ -991,6 +991,9 @@ save( file::AbstractString; kw...) = open(file, "w") do stream; dump save(sid::Symbol, file::AbstractString; kw...) = open(file, "w") do stream; dump(getsession(sid), stream; kw...); end +# ╭───────────────────────────────────────────────────────────────────╮ +# │ HIGH LEVEL FACILITIES │ +# ╰───────────────────────────────────────────────────────────────────╯ # -------------------------------------------------------------------- #= Example: @@ -1031,6 +1034,7 @@ function hist(v::Vector{T}; range=[NaN,NaN], bs=NaN, nbins=0, pad=true) where T end +# -------------------------------------------------------------------- function hist(v1::Vector{T1}, v2::Vector{T2}; range1=[NaN,NaN], bs1=NaN, nbins1=0, range2=[NaN,NaN], bs2=NaN, nbins2=0) where {T1 <: Number, T2 <: Number} @@ -1061,7 +1065,7 @@ function hist(v1::Vector{T1}, v2::Vector{T2}; end - +# -------------------------------------------------------------------- function contourlines(args...; cntrparam="level auto 10") tmpfile = Base.Filesystem.tempname() sid = Symbol("j", Base.Libc.getpid()) @@ -1139,6 +1143,7 @@ function contourlines(args...; cntrparam="level auto 10") end +# -------------------------------------------------------------------- function boxxyerror(x, y; xmin=NaN, ymin=NaN, xmax=NaN, ymax=NaN, cartesian=false) @assert length(x) == length(y) @assert issorted(x) @@ -1171,6 +1176,7 @@ function boxxyerror(x, y; xmin=NaN, ymin=NaN, xmax=NaN, ymax=NaN, cartesian=fals end +# -------------------------------------------------------------------- function histo2segments(in_x, counts) @assert length(in_x) == length(counts) x = Vector{Float64}() diff --git a/test/runtests.jl b/test/runtests.jl index e729eba..79e6e65 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -101,7 +101,8 @@ y = 1.5 * sin.(0.3 .+ 0.7x) ; noise = randn(length(x))./2; e = 0.5 * fill(1, size(x)); -@gp hist(noise, nbins=10) +h = hist(noise, nbins=10) +@gp h.loc h.counts "w histeps" @gp x y @@ -129,14 +130,11 @@ name = "\$MyDataSet1" @gp :- "plot $name u 1:((f(\$1)-\$2) / \$3):(1) w errorbars notit" # Retrieve values for a, b and c -a = 0; b = 0; c = 0; -try - a = parse(Float64, exec("print a")) - b = parse(Float64, exec("print b")) - c = parse(Float64, exec("print c")) -catch -end -gnuplot(:dry) +a = Meta.parse(Gnuplot.exec("print a")) +b = Meta.parse(Gnuplot.exec("print b")) +c = Meta.parse(Gnuplot.exec("print c")) + + @gp :dry "f(x) = a * sin(b + c*x); a = 1; b = 1; c = 1;" :- @gp :- :dry "a = $a; b = $b; c = $c" :- @gp :- :dry "set multiplot layout 2,1" ylab="Data and model" :- @@ -148,8 +146,8 @@ name = "\$MyDataSet1" @gp :- :dry "plot $name u 1:((f(\$1)-\$2) / \$3):(1) w errorbars notit" :- @gp :- :dry save("test.gp") # write on file test.gp -quitall() -exec("load 'test.gp'") # load file test.gp +Gnuplot.quitall() +Gnuplot.exec("load 'test.gp'") # load file test.gp #----------------------------------------------------------------- @gp(""" @@ -214,4 +212,4 @@ exec("load 'test.gp'") # load file test.gp "splot x8, v, (u<0.5) ? -1 : sinc(x8,v) notitle", "splot x9, v, (u<0.5) ? -1 : sinc(x9,v) notitle") -quitall() +Gnuplot.quitall()