Skip to content

Commit

Permalink
use Indexable across all active functions
Browse files Browse the repository at this point in the history
  • Loading branch information
palday committed May 29, 2024
1 parent e724c7f commit 6f58b03
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 20 deletions.
16 changes: 8 additions & 8 deletions src/caterpillar.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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)
Expand All @@ -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
Expand All @@ -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,
Expand All @@ -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)
Expand All @@ -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
Expand Down
8 changes: 4 additions & 4 deletions src/profile.jl
Original file line number Diff line number Diff line change
@@ -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],
Expand All @@ -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='β',
Expand Down Expand Up @@ -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).
Expand All @@ -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='σ',
Expand Down
4 changes: 2 additions & 2 deletions src/shrinkage.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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) .*
Expand Down
12 changes: 6 additions & 6 deletions src/xyplot.jl
Original file line number Diff line number Diff line change
@@ -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)
Expand Down Expand Up @@ -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));
Expand All @@ -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...)
Expand All @@ -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)
Expand Down

0 comments on commit 6f58b03

Please sign in to comment.