From 6f58b031f54bc94759690fe6a29e1d1abff38ffc Mon Sep 17 00:00:00 2001 From: Phillip Alday Date: Tue, 28 May 2024 21:01:52 -0500 Subject: [PATCH] use Indexable across all active functions --- src/caterpillar.jl | 16 ++++++++-------- src/profile.jl | 8 ++++---- src/shrinkage.jl | 4 ++-- src/xyplot.jl | 12 ++++++------ 4 files changed, 20 insertions(+), 20 deletions(-) diff --git a/src/caterpillar.jl b/src/caterpillar.jl index 77e8030..a7b7e41 100644 --- a/src/caterpillar.jl +++ b/src/caterpillar.jl @@ -77,11 +77,11 @@ function ranefinfotable(ri::RanefInfo) end """ - caterpillar!(f::Union{Makie.FigureLike,Makie.GridLayout}, r::RanefInfo; + caterpillar!(f::Indexable, r::RanefInfo; orderby=1, cols::Union{Nothing,AbstractVector}=nothing, dotcolor=(:red, 0.2), barcolor=:black, vline_at_zero::Bool=false) - caterpillar!(f::Union{Makie.FigureLike,Makie.GridLayout}, m::MixedModel, + caterpillar!(f::Indexable, m::MixedModel, gf::Symbol=first(fnames(m)); orderby=1, cols::Union{Nothing,AbstractVector}=nothing, dotcolor=(:red, 0.2), barcolor=:black, @@ -110,7 +110,7 @@ specifying `cols`, either by indices or term names. !!! note `orderby` is the ``n``th column of the columns specified by `cols`. """ -function caterpillar!(f::Union{Makie.FigureLike,Makie.GridLayout}, r::RanefInfo; +function caterpillar!(f::Indexable, r::RanefInfo; orderby=1, cols::Union{Nothing,AbstractVector}=nothing, dotcolor=(:red, 0.2), barcolor=:black, vline_at_zero::Bool=false) @@ -136,7 +136,7 @@ function caterpillar!(f::Union{Makie.FigureLike,Makie.GridLayout}, r::RanefInfo; return f end -function caterpillar!(f::Union{Makie.FigureLike,Makie.GridLayout}, m::MixedModel, +function caterpillar!(f::Indexable, m::MixedModel, gf::Symbol=first(fnames(m)); kwargs...) return caterpillar!(f, ranefinfo(m, gf); kwargs...) end @@ -158,10 +158,10 @@ function caterpillar(m::MixedModel, gf::Symbol=first(fnames(m)); kwargs...) end """ - qqcaterpillar!(f::Union{Makie.FigureLike,Makie.GridLayout}, r::RanefInfo; + qqcaterpillar!(f::Indexable, r::RanefInfo; cols::Union{Nothing,AbstractVector}=nothing, dotcolor=(:red, 0.2), barcolor=:black) - qqcaterpillar!(f::Union{Makie.FigureLike,Makie.GridLayout}, m::MixedModel, + qqcaterpillar!(f::Indexable, m::MixedModel, gf::Symbol=first(fnames(m)); cols::Union{Nothing,AbstractVector}=nothing, dotcolor=(:red, 0.2), barcolor=:black, @@ -181,7 +181,7 @@ of `r.ranef`, usually the `(Intercept)` random effects. Setting `orderby=nothing` will disable sorting, i.e. return the levels in the order they are stored in. """ -function qqcaterpillar!(f::Union{Makie.FigureLike,Makie.GridLayout}, r::RanefInfo; +function qqcaterpillar!(f::Indexable, r::RanefInfo; cols::Union{Nothing,AbstractVector}=nothing, dotcolor=(:red, 0.2), barcolor=:black, vline_at_zero::Bool=false) @@ -206,7 +206,7 @@ function qqcaterpillar!(f::Union{Makie.FigureLike,Makie.GridLayout}, r::RanefInf return f end -function qqcaterpillar!(f::Union{Makie.FigureLike,Makie.GridLayout}, m::MixedModel, +function qqcaterpillar!(f::Indexable, m::MixedModel, gf::Symbol=first(fnames(m)); kwargs...) return qqcaterpillar!(f, ranefinfo(m, gf); kwargs...) end diff --git a/src/profile.jl b/src/profile.jl index d1cf9b6..63b5072 100644 --- a/src/profile.jl +++ b/src/profile.jl @@ -1,5 +1,5 @@ """ - zetaplot!(f::Union{Makie.FigureLike,Makie.GridLayout}, pr::MixedModelProfile; + zetaplot!(f::Indexable, pr::MixedModelProfile; absv=false, ptyp='β', coverage=[.5,.8,.9,.95,.99], @@ -13,7 +13,7 @@ Valid `ptyp` values are 'β', 'σ', and 'θ'. If `absv` is `true` then intervals corresponding to coverage levels in `coverage` are added to each panel. """ -function zetaplot!(f::Union{Makie.FigureLike,Makie.GridLayout}, +function zetaplot!(f::Indexable, pr::MixedModelProfile; absv::Bool=false, # plot abs(zeta) vs parameter value and add intervals ptyp::Char='β', @@ -61,7 +61,7 @@ See [`zetaplot!`](@ref). zetaplot(args...; kwargs...) = zetaplot!(Figure(), args...; kwargs...) """ - profiledensity!(f::Union{Makie.FigureLike,Makie.GridLayout}, pr::MixedModelProfile; + profiledensity!(f::Indexable, pr::MixedModelProfile; ptyp::Char='σ', zbd=3, share_y_scale=true). @@ -73,7 +73,7 @@ Valid `ptyp` values are 'β', 'σ', and 'θ'. If `share_y_scale`, the each facet shares a common y-scale. """ -function profiledensity!(f::Union{Makie.FigureLike,Makie.GridLayout}, +function profiledensity!(f::Indexable, pr::MixedModelProfile; zbd=3, ptyp::Char='σ', diff --git a/src/shrinkage.jl b/src/shrinkage.jl index f770e63..856b50f 100644 --- a/src/shrinkage.jl +++ b/src/shrinkage.jl @@ -37,7 +37,7 @@ function _shrinkage_panel!(ax::Axis, i::Int, j::Int, reref, reest, λ; end """ - shrinkageplot!(f::Union{Makie.FigureLike,Makie.GridLayout}, m::MixedModel, + shrinkageplot!(f::Indexable, m::MixedModel, gf::Symbol=first(fnames(m)), θref; ellipse=false, ellipse_scale=1, n_ellipse=5, cols::Union{Nothing,AbstractVector}=nothing, @@ -62,7 +62,7 @@ unable to see the ellipses, try increasing `ellipse_scale`. For degenerate (singular) models, the correlation ellipse will also be degenerate, i.e., collapse to a point or line. """ -function shrinkageplot!(f::Union{Makie.FigureLike,Makie.GridLayout}, +function shrinkageplot!(f::Indexable, m::MixedModel{T}, gf::Symbol=first(fnames(m)), θref::AbstractVector{T}=(isa(m, LinearMixedModel) ? 1e4 : 1) .* diff --git a/src/xyplot.jl b/src/xyplot.jl index 2f94a40..d85a395 100644 --- a/src/xyplot.jl +++ b/src/xyplot.jl @@ -1,9 +1,9 @@ """ - clevelandaxes!(f::Union{Makie.FigureLike,Makie.GridLayout}, labs, layout) + clevelandaxes!(f::Indexable, labs, layout) Create a set of axes within `f` with rows, columns determined by `layout` sufficient to hold `labs` """ -function clevelandaxes!(f::Union{Makie.FigureLike,Makie.GridLayout}, labs, layout) +function clevelandaxes!(f::Indexable, labs, layout) nrow, ncol = layout npanel = length(labs) axs = sizehint!(Axis[], npanel) @@ -48,13 +48,13 @@ function simplelinreg(x, y) end """ - splom!(f::Union{Makie.FigureLike,Makie.GridLayout}, df::DataFrame) + splom!(f::Indexable, df::DataFrame) Create a scatter-plot matrix in `f` from the columns of `df`. Non-numeric columns are ignored. """ -function splom!(f::Union{Makie.FigureLike,Makie.GridLayout}, df::DataFrame; +function splom!(f::Indexable, df::DataFrame; addcontours::Bool=false) n_cols = ncol(df) df = select(df, findall(col -> eltype(col) <: Number, eachcol(df)); @@ -72,7 +72,7 @@ function splom!(f::Union{Makie.FigureLike,Makie.GridLayout}, df::DataFrame; end """ - splomaxes!(f::Union{Makie.FigureLike,Makie.GridLayout}, labels::AbstractVector{<:AbstractString}, + splomaxes!(f::Indexable, labels::AbstractVector{<:AbstractString}, panel!::Function, args...; extraticks::Bool=false, kwargs...) @@ -81,7 +81,7 @@ where `k` is the length of `labels`. The `panel!` function should have the sign `panel!(ax::Axis, i::Integer, j::Integer, args...; kwargs...)` and should draw the [i,j] panel in `ax`. """ -function splomaxes!(f::Union{Makie.FigureLike,Makie.GridLayout}, +function splomaxes!(f::Indexable, labels::AbstractVector{<:AbstractString}, panel!::Function, args...; extraticks::Bool=false, kwargs...) k = length(labels)