Skip to content

Commit 135ab62

Browse files
paldaydmbates
andauthored
Option for no sorting in caterpillarplot! (#12)
* Zenodo badge * orderby nothing * patch bump * remove extra newline * use the correct index * drop support for julia-1.5 * swap to PNG due to SVG bug * sorting note * Tighten the code a bit. Co-authored-by: Douglas Bates <[email protected]>
1 parent a948ac4 commit 135ab62

File tree

6 files changed

+21
-8
lines changed

6 files changed

+21
-8
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ jobs:
2121
runs-on: ${{ matrix.os }}
2222
strategy:
2323
matrix:
24-
version: [1.5, 1]
24+
version: [1]
2525
arch: [x64]
2626
os: [ubuntu-18.04] # macos-10.15, windows-2019
2727
steps:

Project.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "MixedModelsMakie"
22
uuid = "b12ae82c-6730-437f-aff9-d2c38332a376"
3-
authors = ["Phillip Alday <[email protected]> and contributors"]
4-
version = "0.1.0"
3+
authors = ["Phillip Alday <[email protected]>, Douglas Bates <[email protected]> and contributors"]
4+
version = "0.1.1"
55

66
[deps]
77
AbstractPlotting = "537997a7-5e4e-5d89-9595-2241ea00577e"
@@ -13,7 +13,7 @@ MixedModels = "ff71e718-51f3-5ec2-a782-8ffcbfa3c316"
1313
AbstractPlotting = "0.18"
1414
DataFrames = "1"
1515
MixedModels = "3.6, 4"
16-
julia = "1.5"
16+
julia = "1.6"
1717

1818
[extras]
1919
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
[![Stable Docs][docs-stable-img]][docs-stable-url]
55
[![Dev Docs][docs-dev-img]][docs-dev-url]
66
[![Codecov](https://codecov.io/gh/palday/MixedModelsMakie.jl/branch/master/graph/badge.svg)](https://codecov.io/gh/palday/MixedModelsMakie.jl)
7+
[![DOI](https://zenodo.org/badge/337082315.svg)](https://zenodo.org/badge/latestdoi/337082315)
8+
79

810
[docs-dev-img]: https://img.shields.io/badge/docs-dev-blue.svg
911
[docs-dev-url]: https://palday.github.io/MixedModelsMakie.jl/dev

docs/src/api.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ caterpillar!
2828

2929
```@example Caterpillar
3030
using CairoMakie
31-
CairoMakie.activate!(type = "svg")
31+
CairoMakie.activate!(type = "png")
3232
using MixedModels
3333
using MixedModelsMakie
3434
sleepstudy = MixedModels.dataset(:sleepstudy)
@@ -43,6 +43,10 @@ caterpillar!(Figure(; resolution=(800,600)), subjre)
4343
caterpillar!(Figure(; resolution=(800,600)), subjre; orderby=2)
4444
```
4545

46+
```@example Caterpillar
47+
caterpillar!(Figure(; resolution=(800,600)), subjre; orderby=nothing)
48+
```
49+
4650
## Shrinkage Plots
4751

4852
```@docs

src/MixedModelsMakie.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,4 @@ module MixedModelsMakie
2020
include("caterpillar.jl")
2121
include("xyplot.jl")
2222

23-
end
23+
end # module

src/caterpillar.jl

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,19 @@ Add Axes of a caterpillar plot from `r` to `f`.
4444
4545
The order of the levels on the vertical axes is increasing `orderby` column
4646
of `r.ranef`, usually the `(Intercept)` random effects.
47+
Setting `orderby=nothing` will disable sorting, i.e. return the levels in the
48+
order they are stored in.
49+
50+
!!! note
51+
Even when not sorting the levels, they might have already been sorted during
52+
model matrix construction. If you want impose a particular ordering on the
53+
levels, then you must sort the relevant fields in the `RanefInfo` object before
54+
calling `caterpillar!`.
4755
"""
4856
function caterpillar!(f::Figure, r::RanefInfo; orderby=1)
4957
rr = r.ranef
50-
vv = view(rr, :, orderby)
51-
ord = sortperm(vv)
5258
y = axes(rr, 1)
59+
ord = isnothing(orderby) ? y : sortperm(view(rr, :, orderby))
5360
cn = r.cnames
5461
axs = [Axis(f[1, j]) for j in axes(rr, 2)]
5562
linkyaxes!(axs...)

0 commit comments

Comments
 (0)