Minor changes

This commit is contained in:
Giorgio Calderone 2020-03-16 19:48:47 +01:00
parent 3283f54741
commit 8abedcc163
2 changed files with 17 additions and 13 deletions

View File

@ -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 save(sid::Symbol, file::AbstractString; kw...) = open(file, "w") do stream; dump(getsession(sid), stream; kw...); end
# ╭───────────────────────────────────────────────────────────────────╮
# │ HIGH LEVEL FACILITIES │
# ╰───────────────────────────────────────────────────────────────────╯
# -------------------------------------------------------------------- # --------------------------------------------------------------------
#= #=
Example: Example:
@ -1031,6 +1034,7 @@ function hist(v::Vector{T}; range=[NaN,NaN], bs=NaN, nbins=0, pad=true) where T
end end
# --------------------------------------------------------------------
function hist(v1::Vector{T1}, v2::Vector{T2}; function hist(v1::Vector{T1}, v2::Vector{T2};
range1=[NaN,NaN], bs1=NaN, nbins1=0, range1=[NaN,NaN], bs1=NaN, nbins1=0,
range2=[NaN,NaN], bs2=NaN, nbins2=0) where {T1 <: Number, T2 <: Number} 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 end
# --------------------------------------------------------------------
function contourlines(args...; cntrparam="level auto 10") function contourlines(args...; cntrparam="level auto 10")
tmpfile = Base.Filesystem.tempname() tmpfile = Base.Filesystem.tempname()
sid = Symbol("j", Base.Libc.getpid()) sid = Symbol("j", Base.Libc.getpid())
@ -1139,6 +1143,7 @@ function contourlines(args...; cntrparam="level auto 10")
end end
# --------------------------------------------------------------------
function boxxyerror(x, y; xmin=NaN, ymin=NaN, xmax=NaN, ymax=NaN, cartesian=false) function boxxyerror(x, y; xmin=NaN, ymin=NaN, xmax=NaN, ymax=NaN, cartesian=false)
@assert length(x) == length(y) @assert length(x) == length(y)
@assert issorted(x) @assert issorted(x)
@ -1171,6 +1176,7 @@ function boxxyerror(x, y; xmin=NaN, ymin=NaN, xmax=NaN, ymax=NaN, cartesian=fals
end end
# --------------------------------------------------------------------
function histo2segments(in_x, counts) function histo2segments(in_x, counts)
@assert length(in_x) == length(counts) @assert length(in_x) == length(counts)
x = Vector{Float64}() x = Vector{Float64}()

View File

@ -101,7 +101,8 @@ y = 1.5 * sin.(0.3 .+ 0.7x) ;
noise = randn(length(x))./2; noise = randn(length(x))./2;
e = 0.5 * fill(1, size(x)); 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 @gp x y
@ -129,14 +130,11 @@ name = "\$MyDataSet1"
@gp :- "plot $name u 1:((f(\$1)-\$2) / \$3):(1) w errorbars notit" @gp :- "plot $name u 1:((f(\$1)-\$2) / \$3):(1) w errorbars notit"
# Retrieve values for a, b and c # Retrieve values for a, b and c
a = 0; b = 0; c = 0; a = Meta.parse(Gnuplot.exec("print a"))
try b = Meta.parse(Gnuplot.exec("print b"))
a = parse(Float64, exec("print a")) c = Meta.parse(Gnuplot.exec("print c"))
b = parse(Float64, exec("print b"))
c = parse(Float64, exec("print c"))
catch
end
gnuplot(:dry)
@gp :dry "f(x) = a * sin(b + c*x); a = 1; b = 1; c = 1;" :- @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 "a = $a; b = $b; c = $c" :-
@gp :- :dry "set multiplot layout 2,1" ylab="Data and model" :- @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 "plot $name u 1:((f(\$1)-\$2) / \$3):(1) w errorbars notit" :-
@gp :- :dry @gp :- :dry
save("test.gp") # write on file test.gp save("test.gp") # write on file test.gp
quitall() Gnuplot.quitall()
exec("load 'test.gp'") # load file test.gp Gnuplot.exec("load 'test.gp'") # load file test.gp
#----------------------------------------------------------------- #-----------------------------------------------------------------
@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 x8, v, (u<0.5) ? -1 : sinc(x8,v) notitle",
"splot x9, v, (u<0.5) ? -1 : sinc(x9,v) notitle") "splot x9, v, (u<0.5) ? -1 : sinc(x9,v) notitle")
quitall() Gnuplot.quitall()