Added cblabel keyword; disabled binary format for tables; accept scalar float as column

This commit is contained in:
Giorgio Calderone 2020-04-07 20:15:09 +02:00
parent f97fd7f5eb
commit 798e675424

View File

@ -105,6 +105,7 @@ function parseKeywords(; kwargs...)
xlabel=AbstractString, xlabel=AbstractString,
ylabel=AbstractString, ylabel=AbstractString,
zlabel=AbstractString, zlabel=AbstractString,
cblabel=AbstractString,
xlog=Bool, xlog=Bool,
ylog=Bool, ylog=Bool,
zlog=Bool) zlog=Bool)
@ -120,6 +121,7 @@ function parseKeywords(; kwargs...)
ismissing(kw.xlabel ) || (push!(out, "set xlabel \"" * kw.xlabel * "\"")) ismissing(kw.xlabel ) || (push!(out, "set xlabel \"" * kw.xlabel * "\""))
ismissing(kw.ylabel ) || (push!(out, "set ylabel \"" * kw.ylabel * "\"")) ismissing(kw.ylabel ) || (push!(out, "set ylabel \"" * kw.ylabel * "\""))
ismissing(kw.zlabel ) || (push!(out, "set zlabel \"" * kw.zlabel * "\"")) ismissing(kw.zlabel ) || (push!(out, "set zlabel \"" * kw.zlabel * "\""))
ismissing(kw.zlabel ) || (push!(out, "set cblabel \"" * kw.cblabel * "\""))
ismissing(kw.xlog ) || (push!(out, (kw.xlog ? "" : "un") * "set logscale x")) ismissing(kw.xlog ) || (push!(out, (kw.xlog ? "" : "un") * "set logscale x"))
ismissing(kw.ylog ) || (push!(out, (kw.ylog ? "" : "un") * "set logscale y")) ismissing(kw.ylog ) || (push!(out, (kw.ylog ? "" : "un") * "set logscale y"))
ismissing(kw.zlog ) || (push!(out, (kw.zlog ? "" : "un") * "set logscale z")) ismissing(kw.zlog ) || (push!(out, (kw.zlog ? "" : "un") * "set logscale z"))
@ -462,8 +464,8 @@ end
# ╰───────────────────────────────────────────────────────────────────╯ # ╰───────────────────────────────────────────────────────────────────╯
#= #=
The following has been dismissed since `binary matrix` do not The following is dismissed since `binary matrix` do not allows to use
allows to use keywords such as `rotate`. keywords such as `rotate`.
# --------------------------------------------------------------------- # ---------------------------------------------------------------------
function write_binary(M::Matrix{T}) where T <: Number function write_binary(M::Matrix{T}) where T <: Number
x = collect(1:size(M)[1]) x = collect(1:size(M)[1])
@ -551,6 +553,15 @@ end
# --------------------------------------------------------------------- # ---------------------------------------------------------------------
#=
The following is dismissed since the following doesn't work:
x = randn(10000)
@gp x x x "w p lc pal"
It requires:
@gp x x x "u 1:2:3 w p lc pal"
function write_binary(cols::Vararg{AbstractVector, N}) where N function write_binary(cols::Vararg{AbstractVector, N}) where N
gpsource = "binary record=$(length(cols[1])) format='" gpsource = "binary record=$(length(cols[1])) format='"
types = Vector{DataType}() types = Vector{DataType}()
@ -579,6 +590,8 @@ function write_binary(cols::Vararg{AbstractVector, N}) where N
close(io) close(io)
return (path, gpsource) return (path, gpsource)
end end
=#
# ╭───────────────────────────────────────────────────────────────────╮ # ╭───────────────────────────────────────────────────────────────────╮
# │ PRIVATE FUNCTIONS TO MANIPULATE SESSIONS │ # │ PRIVATE FUNCTIONS TO MANIPULATE SESSIONS │
@ -855,9 +868,12 @@ end
# --------------------------------------------------------------------- # ---------------------------------------------------------------------
function driver(args...; flag3d=false) function driver(args...; flag3d=false)
function validate_datatype(d) function validate_datatype(d)
# Return true if the array element type can be handled by the `tostring` function # Return true if the data type can be handled by the `tostring` function
isa(d, AbstractArray) || return false if isa(d, AbstractArray)
t = valtype(d) t = valtype(d)
else
t = typeof(d)
end
if (t <: String) || if (t <: String) ||
(t <: Number) || (t <: Number) ||
(t <: ColorTypes.RGB) || (t <: ColorTypes.RGB) ||
@ -994,7 +1010,10 @@ function driver(args...; flag3d=false)
push!(dataset, arg.counts) push!(dataset, arg.counts)
plotspec = "w image notit" plotspec = "w image notit"
dataset_completed() dataset_completed()
elseif isa(arg, AbstractArray)# ==> a dataset elseif isa(arg, AbstractArray) # ==> a dataset column
@assert validate_datatype(arg) "Invalid argument type at position $iarg"
push!(dataset, arg)
elseif isa(arg, Real) # ==> a dataset column with only one row
@assert validate_datatype(arg) "Invalid argument type at position $iarg" @assert validate_datatype(arg) "Invalid argument type at position $iarg"
push!(dataset, arg) push!(dataset, arg)
else else