From 994b543add15fa986fd72ab66dcde3844229b709 Mon Sep 17 00:00:00 2001 From: Moelf Date: Fri, 2 Oct 2020 15:08:59 -0400 Subject: [PATCH 1/3] add slice_arg for AbstractRange --- src/args.jl | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/args.jl b/src/args.jl index 7466dce9..19b4af21 100644 --- a/src/args.jl +++ b/src/args.jl @@ -1238,6 +1238,7 @@ convertLegendValue(v::AbstractArray) = map(convertLegendValue, v) # 1-row matrices will give an element # multi-row matrices will give a column # InputWrapper just gives the contents +# AbstractRange gives (first, last) tuple # anything else is returned as-is function slice_arg(v::AMat, idx::Int) c = mod1(idx, size(v,2)) @@ -1245,6 +1246,7 @@ function slice_arg(v::AMat, idx::Int) size(v,1) == 1 ? v[first(m),n[c]] : v[:,n[c]] end slice_arg(wrapper::InputWrapper, idx) = wrapper.obj +slice_arg(v::AbstractRange, idx) = (first(v), last(v)) slice_arg(v, idx) = v From bdcc8cdb8d9af25b3f72a0b1dae74b99bb9577c4 Mon Sep 17 00:00:00 2001 From: Moelf Date: Sat, 3 Oct 2020 15:33:19 -0400 Subject: [PATCH 2/3] Alternative approach --- src/args.jl | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/args.jl b/src/args.jl index 19b4af21..e0f4b066 100644 --- a/src/args.jl +++ b/src/args.jl @@ -1238,7 +1238,6 @@ convertLegendValue(v::AbstractArray) = map(convertLegendValue, v) # 1-row matrices will give an element # multi-row matrices will give a column # InputWrapper just gives the contents -# AbstractRange gives (first, last) tuple # anything else is returned as-is function slice_arg(v::AMat, idx::Int) c = mod1(idx, size(v,2)) @@ -1246,7 +1245,6 @@ function slice_arg(v::AMat, idx::Int) size(v,1) == 1 ? v[first(m),n[c]] : v[:,n[c]] end slice_arg(wrapper::InputWrapper, idx) = wrapper.obj -slice_arg(v::AbstractRange, idx) = (first(v), last(v)) slice_arg(v, idx) = v @@ -1491,6 +1489,10 @@ function _update_axis(axis::Axis, plotattributes_in::AKW, letter::Symbol, subplo # then get those args that were passed with a leading letter: `xlabel = "X"` lk = Symbol(letter, k) if haskey(plotattributes_in, lk) + # warn against using range in x,y,z lims + if k==:lims && plotattributes_in[lk] isa AbstractRange + @warn("$lk should be a Tuple") + end kw[k] = slice_arg(plotattributes_in[lk], subplot_index) end end From 083fe899050d6ee77cb8b7812685cd059e17b042 Mon Sep 17 00:00:00 2001 From: Moelf Date: Mon, 5 Oct 2020 00:53:12 -0400 Subject: [PATCH 3/3] alternative approach --- src/args.jl | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/args.jl b/src/args.jl index e0f4b066..9ff0ab69 100644 --- a/src/args.jl +++ b/src/args.jl @@ -1489,10 +1489,6 @@ function _update_axis(axis::Axis, plotattributes_in::AKW, letter::Symbol, subplo # then get those args that were passed with a leading letter: `xlabel = "X"` lk = Symbol(letter, k) if haskey(plotattributes_in, lk) - # warn against using range in x,y,z lims - if k==:lims && plotattributes_in[lk] isa AbstractRange - @warn("$lk should be a Tuple") - end kw[k] = slice_arg(plotattributes_in[lk], subplot_index) end end @@ -1539,8 +1535,16 @@ function _update_subplot_args(plt::Plot, sp::Subplot, plotattributes_in, subplot _update_subplot_periphery(sp, anns) _update_subplot_colors(sp) + lims_warned = false for letter in (:x, :y, :z) _update_axis(plt, sp, plotattributes_in, letter, subplot_index) + lk = Symbol(letter, :lims) + + # warn against using `Range` in x,y,z lims + if !lims_warned && haskey(plotattributes_in, lk) && plotattributes_in[lk] isa AbstractRange + @warn("lims should be a Tuple, not $(typeof(plotattributes_in[lk])).") + lims_warned = true + end end end