@@ -156,7 +156,7 @@ function _common_plot_xyz(cmd0::String, arg1, caller::String, O::Bool, K::Bool,
156156 opt_W:: String = add_opt_pen (d, [:W :pen ], opt= " W" )
157157 arg1, opt_W, got_color_line_grad, made_it_vector = helper_psxy_line (d, cmd, opt_W, is3D, arg1, arg2, arg3)
158158
159- arg1, cmd = check_ribbon (d, arg1, cmd, opt_W) # Do this check here, after -W is known and before parsing -G & -L
159+ isa ( arg1, GDtype) && (arg1, cmd = check_ribbon (d, arg1, cmd, opt_W) ) # Do this check here, after -W is known and before parsing -G & -L
160160
161161 mcc, bar_ok = false , (sub_module == " bar" && ! check_bar_group (arg1))
162162 if (! got_color_line_grad && ! is_gridtri && (arg1 != = nothing && ! isa (arg1, GMTcpt)) && ((! got_Zvars && ! is_ternary) || bar_ok))
259259
260260# ---------------------------------------------------------------------------------------------------
261261# If the input is a GMTdataset and one of its columns is a Time column, automatically set the -fT
262- function set_fT (D:: GMTdataset , cmd:: String , opt_f:: String )
262+ function set_fT (D:: GMTdataset{T,N} , cmd:: String , opt_f:: String ):: String where {T,N}
263263 if ((Tc = get (D. attrib, " Timecol" , " " )) != " " )
264264 tc:: Int = parse (Int, Tc) - 1
265265 _opt_f = (opt_f == " " ) ? " -f$(tc) T" : opt_f * " ,$(tc) T"
@@ -284,7 +284,7 @@ function parse_grid2tri_case(d, cmd, caller, is3D, isFV, O, arg1)
284284 (opt_p == " " && ! is3D && ! O) && (CURRENT_VIEW[1 ] = " " ) # Make sure it empty under these conditions
285285 (opt_p == " " ) ? (opt_p = CURRENT_VIEW[1 ]; cmd *= opt_p) : (CURRENT_VIEW[1 ] = opt_p) # Save for eventual use in other modules.
286286
287- if (is3D && isFV) # case of 3D faces
287+ if (is3D && isFV) # case of 3D faces
288288 arg1 = (is_in_dict (d, [:replicate ]) != = nothing ) ? replicant (arg1, d) : deal_faceverts (arg1, d; del= find_in_dict (d, [:nocull ])[1 ] === nothing )
289289 (! O && ! haskey (d, :aspect3 ) && is_in_dict (d, [:JZ :Jz :zsize :zscale ]) === nothing && ! isgeog (arg1)) && (d[:aspect3 ] = " equal" )
290290 (! O && ! haskey (d, :aspect3 ) && isgeog (arg1)) && (d[:aspect ] = " equal" )
@@ -296,12 +296,12 @@ function parse_grid2tri_case(d, cmd, caller, is3D, isFV, O, arg1)
296296end
297297
298298# ---------------------------------------------------------------------------------------------------
299- function parse_Ebars (d, cmd, arg1)
299+ function parse_Ebars (d:: Dict{Symbol, Any} , cmd:: String , arg1)
300300 got_Ebars = false
301301 val, symb = find_in_dict (d, [:E :error :errorbars :error_bars ], false )
302302 if (val != = nothing )
303303 if isa (val, String)
304- cmd *= " -E" * val
304+ cmd:: String *= " -E" * val
305305 else
306306 _mat = (arg1 === nothing ) ? arg1 : isa (arg1, GMTdataset) ? arg1. data : arg1[1 ]. data
307307 cmd, mat_t = add_opt (add_opt, (d, cmd, " E" , [symb]),
@@ -316,7 +316,7 @@ function parse_Ebars(d, cmd, arg1)
316316end
317317
318318# ---------------------------------------------------------------------------------------------------
319- function parse_color_request (d, cmd, N_args, arg1, arg2)
319+ function parse_color_request (d:: Dict{Symbol, Any} , cmd:: String , N_args:: Int , arg1, arg2)
320320 opt_Z, args, n, got_Zvars = add_opt (d, " " , " Z" , [:Z :level :levels ], :data , Any[arg1, arg2], (outline= " _o" , nofill= " _f" ))
321321 (opt_Z == " -Z" && n == 0 ) && error (" The 'level' option (Z) must be set a single value, a file name or a vector os reals." )
322322 if (isa (arg1, Vector{<: GMTdataset }) && ((ind_att = findfirst (' =' , opt_Z)) != = nothing ))
@@ -353,7 +353,7 @@ function set_avatar_defaults(d, cmd, mcc, caller, got_usr_R, opt_B, opt_Gsymb, o
353353end
354354
355355# ---------------------------------------------------------------------------------------------------
356- function parse_plot_G_L (d, cmd, g_bar_fill, is_ternary)
356+ function parse_plot_G_L (d:: Dict{Symbol, Any} , cmd:: String , g_bar_fill:: Vector{String} , is_ternary:: Bool )
357357 opt_G:: String = " "
358358 if (isempty (g_bar_fill)) # Otherwise bar fill colors are dealt with somewhere else
359359 ((opt_G = add_opt_fill (" " , d, [:G :fill ], ' G' )) != " " ) && (cmd *= opt_G) # Also keep track if -G was set
@@ -374,7 +374,7 @@ function parse_plot_G_L(d, cmd, g_bar_fill, is_ternary)
374374end
375375
376376# ---------------------------------------------------------------------------------------------------
377- function parse_plot_callers (d, gmt_proggy, caller, is3D, O, arg1)
377+ function parse_plot_callers (d:: Dict{Symbol, Any} , gmt_proggy:: String , caller:: String , is3D:: Bool , O:: Bool , arg1)
378378 isFV = (isa (arg1, GMTfv) || isa (arg1, Vector{GMTfv}))
379379 (arg1 != = nothing && ! isa (arg1, GDtype) && ! isa (arg1, Matrix{<: Real }) && ! isFV) &&
380380 (arg1 = tabletypes2ds (arg1, ((val = find_in_dict (d, [:interp ])[1 ]) != = nothing ) ? interp= val : interp= 0 ))
@@ -407,9 +407,9 @@ function parse_plot_callers(d, gmt_proggy, caller, is3D, O, arg1)
407407end
408408
409409# ---------------------------------------------------------------------------------------------------
410- plt_txt_attrib! (D:: GMTdataset , d:: Dict , _cmd:: Vector{String} ) = plt_txt_attrib! ([D], d, _cmd)
411- function plt_txt_attrib! (D:: Vector{<:GMTdataset} , d:: Dict , _cmd:: Vector{String} )
412- # Plot TEXT attributed labels and serve as function barrier agains to f Anys
410+ plt_txt_attrib! (D:: GMTdataset{T,N} , d:: Dict{Symbol, Any} , _cmd:: Vector{String} ) where {T,N} = plt_txt_attrib! ([D], d, _cmd)
411+ function plt_txt_attrib! (D:: Vector{<:GMTdataset{T,N}} , d:: Dict{Symbol, Any} , _cmd:: Vector{String} ) where {T,N}
412+ # Plot TEXT attributed labels and serve as function barrier agains the f Any's (not sure if succeeds)
413413 ((val = find_in_dict (d, [:labels ])[1 ]) === nothing ) && return nothing
414414
415415 s_val:: String = string (val)
@@ -422,13 +422,13 @@ function plt_txt_attrib!(D::Vector{<:GMTdataset}, d::Dict, _cmd::Vector{String})
422422 if ((fnt = add_opt (d, " " , " " , [:font ], (angle= " +a" , font= (" +f" , font)); del= false )) != " " )
423423 (fnt[1 ] != ' +' ) && (fnt = " +f" * fnt)
424424 delete! (d, :font )
425- ct. text = make_attrtbl (D, att= ts)[1 ]
425+ ct. text = vec ( make_attrtbl (D, att= ts)[1 ])
426426 else
427427 nc:: Int = round (Int, sqrt (length (D))) # A crude guess of the number of columns
428428 fnt = (nc < 5 ) ? " 7p" : (nc < 9 ? " 5p" : " 4p" ) # A simple heuristic
429429 outline = fnt * " ,black=~0.75p,white " # Apply the outline trick
430430 fnt = " +f"
431- ct. text = outline .* make_attrtbl (D, att= ts)[1 ]
431+ ct. text = outline .* vec ( make_attrtbl (D, att= ts)[1 ])
432432 end
433433 (CTRL. pocket_call[1 ] === nothing ) ? (CTRL. pocket_call[1 ] = ct) : (CTRL. pocket_call[2 ] = ct)
434434 append! (_cmd, [" pstext -R -J -F" * fnt * " +jMC" ])
@@ -510,7 +510,7 @@ function if_multicols(d, arg1, is3D::Bool)
510510 MULTI_COL[1 ] && (d2[:multi ] = true ) # MULTI_COL was set in cat_2_arg2() when 2nd arg had 2 or more cols.
511511 arg1 = ds2ds (arg1; is3D= is3D, d2... ) # Pass a 'd' copy and remove possible kw that are also parsed in psxy
512512 delete! (d, [[:multi , :multicol , :multicols ], [:lt , :linethick ], [:ls , :linestyle ], [:fill ], [:fillalpha ], [:color ]])
513- MULTI_COL[1 ] = false # If it was true, its jobe is done.
513+ MULTI_COL[1 ] = false # If it was true, its jobe is done.
514514 return arg1
515515end
516516
@@ -545,6 +545,7 @@ function check_grouping!(d, arg1)
545545end
546546
547547# ---------------------------------------------------------------------------------------------------
548+ #=
548549function check_ribbon(d, arg1, cmd::String, opt_W::String)
549550 ((val = find_in_dict(d, [:ribbon :band])[1]) === nothing) && return arg1, cmd
550551 add_2 = true
@@ -561,6 +562,7 @@ function check_ribbon(d, arg1, cmd::String, opt_W::String)
561562 else
562563 error("Wrong data type for ribbon/band $(typeof(val))")
563564 end
565+ ec1, ec2, add_2 = helper_check_ribbon(val)
564566 if (isa(arg1, Vector{<:GMTdataset}))
565567 if (add_2)
566568 for k = 1:numel(arg1) add2ds!(arg1[k], ec2; names=["Zbnd1","Zbnd2"]) end
@@ -574,6 +576,49 @@ function check_ribbon(d, arg1, cmd::String, opt_W::String)
574576 (!occursin(cmd, "-W") && opt_W == "") && (cmd *= " -W0.5p") # Do not leave without a line specification
575577 return arg1, cmd
576578end
579+ =#
580+
581+ function check_ribbon (d, arg1:: GMTdataset{T,N} , cmd:: String , opt_W:: String ) where {T,N}
582+ ((val = find_in_dict (d, [:ribbon :band ])[1 ]) === nothing ) && return arg1, cmd
583+ ec1, ec2, add_2 = helper_check_ribbon (val) # Function barrier agains Anys
584+ (add_2) ? add2ds! (arg1, ec2; names= [" Zbnd1" ," Zbnd2" ]) : add2ds! (arg1, ec1; name= " Zbnd" )
585+ d[:L ] = (add_2) ? " +D" : " +d"
586+ (! occursin (cmd, " -W" ) && opt_W == " " ) && (cmd *= " -W0.5p" ) # Do not leave without a line specification
587+ return arg1, cmd
588+ end
589+
590+ function check_ribbon (d, arg1:: Vector{<:GMTdataset{T,N}} , cmd:: String , opt_W:: String ) where {T,N}
591+ ((val = find_in_dict (d, [:ribbon :band ])[1 ]) === nothing ) && return arg1, cmd
592+ ec1, ec2, add_2 = helper_check_ribbon (val) # Function barrier agains Anys
593+ if (add_2)
594+ for k = 1 : numel (arg1) add2ds! (arg1[k], ec2; names= [" Zbnd1" ," Zbnd2" ]) end
595+ else
596+ for k = 1 : numel (arg1) add2ds! (arg1[k], ec1; name= " Zbnd" ) end
597+ end
598+ d[:L ] = (add_2) ? " +D" : " +d"
599+ (! occursin (cmd, " -W" ) && opt_W == " " ) && (cmd *= " -W0.5p" ) # Do not leave without a line specification
600+ return arg1, cmd
601+ end
602+
603+ function helper_check_ribbon (val):: Tuple{Vector{Float64}, Matrix{Float64}, Bool}
604+ # Isolate here the fact that 'val' is a Any
605+ add_2 = true
606+ ec1, ec2 = Float64[], Matrix{Float64}[]
607+ if isa (val, Real)
608+ ec1 = repeat ([float (val):: Float64 ], size (arg1,1 ):: Int )
609+ add_2 = false
610+ elseif (isa (val, VecOrMat{<: Real }) || isa (val, Tuple{<: Real , <: Real }))
611+ (length (val):: Int == 2 ) ? (ec2 = repeat ([float (val[1 ]):: Float64 float (val[2 ]):: Float64 ], size (arg1,1 ):: Int )) :
612+ ec2 = [Float64 .(vec (val)) Float64 .(vec (val))]
613+ elseif isa (val, Tuple{Vector{<: Real }, Vector{<: Real }})
614+ ec2 = [Float64 .(val[1 ]) Float64 .(val[2 ])]
615+ elseif (isa (val, Matrix{<: Real }) && size (val,2 ) == 2 )
616+ ec2 = val
617+ else
618+ error (" Wrong data type for ribbon/band $(typeof (val)) " )
619+ end
620+ ec1, ec2, add_2
621+ end
577622
578623# ---------------------------------------------------------------------------------------------------
579624function with_xyvar (d:: Dict , arg1:: GMTdataset , no_x:: Bool = false ):: Union{GMTdataset, Vector{<:GMTdataset}}
0 commit comments