Skip to content

Commit

Permalink
reduce snapshot sizes
Browse files Browse the repository at this point in the history
  • Loading branch information
mjskay committed Jan 13, 2024
1 parent ccaeaf6 commit f230423
Show file tree
Hide file tree
Showing 8 changed files with 93 additions and 90 deletions.
3 changes: 3 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

New features and enhancements:

* The `geom_slabinterval()` and `geom_dotsinterval()` families gain "sub-guides",
which can be passed to the `subguide` parameter to create axis annotations for
the `thickness` aesthetic (for slabs) and the dot count (for dots) (#183).
* The `weight` aesthetic is now supported in `stat_slabinterval()`, including
weighted calculations for densities, CDFs, all interval types (quantile
intervals, highest density intervals, and highest density continuous intervals),
Expand Down
5 changes: 4 additions & 1 deletion R/geom_dotsinterval.R
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@ dots_grob = function(data, x, y, xscale = 1,
verbose = FALSE,
orientation = "vertical"
) {
datas = data %>%
# drop the dist columns because they can be expensive and we don't need them
# after this point
keep_cols = !(names(data) %in% c("xdist", "ydist", "dist"))
datas = data[, keep_cols, drop = FALSE] %>%
group_by_at(c("group", y)) %>%
group_split()

Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
39 changes: 20 additions & 19 deletions tests/testthat/test.subguide.R
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ test_that("slab subguide works with dodging", {
position = "dodgejust",
height = 0.9,
scale = 0.8,
normalize = "groups"
normalize = "groups",
n = 11
)
)
})
Expand All @@ -45,25 +46,25 @@ test_that("slab subguide positioning works", {
sg = subguide_axis(title = "test", label_side = "inside", theme = theme_test())
vdiffr::expect_doppelganger("slab subguide with inside labels",
p +
stat_slabinterval(aes(y = "1"), subguide = sg(position = 1)) +
stat_slabinterval(aes(y = "0.5"), subguide = sg(position = 0.5)) +
stat_slabinterval(aes(y = "0"), subguide = sg(position = 0)) +
stat_slabinterval(aes(y = "left"), subguide = sg(position = "left")) +
stat_slabinterval(aes(y = "right"), subguide = sg(position = "right")) +
stat_slabinterval(aes(y = "right, just = 1"), subguide = sg(position = "right", just = 1)) +
stat_slabinterval(aes(y = "1"), subguide = sg(position = 1), n = 5) +
stat_slabinterval(aes(y = "0.5"), subguide = sg(position = 0.5), n = 5) +
stat_slabinterval(aes(y = "0"), subguide = sg(position = 0), n = 5) +
stat_slabinterval(aes(y = "left"), subguide = sg(position = "left"), n = 5) +
stat_slabinterval(aes(y = "right"), subguide = sg(position = "right"), n = 5) +
stat_slabinterval(aes(y = "right, just = 1"), subguide = sg(position = "right", just = 1), n = 5) +
theme_test() +
theme(plot.margin = margin(5.5,50,5.5,5.5))
)

sg = subguide_axis(title = "test", label_side = "outside", theme = theme_test())
vdiffr::expect_doppelganger("slab subguide with outside labels",
p +
stat_slabinterval(aes(y = "1"), subguide = sg(position = 1)) +
stat_slabinterval(aes(y = "0.5"), subguide = sg(position = 0.5)) +
stat_slabinterval(aes(y = "0"), subguide = sg(position = 0)) +
stat_slabinterval(aes(y = "left"), subguide = sg(position = "left")) +
stat_slabinterval(aes(y = "right"), subguide = sg(position = "right")) +
stat_slabinterval(aes(y = "right, just = 1"), subguide = sg(position = "right", just = 1)) +
stat_slabinterval(aes(y = "1"), subguide = sg(position = 1), n = 5) +
stat_slabinterval(aes(y = "0.5"), subguide = sg(position = 0.5), n = 5) +
stat_slabinterval(aes(y = "0"), subguide = sg(position = 0), n = 5) +
stat_slabinterval(aes(y = "left"), subguide = sg(position = "left"), n = 5) +
stat_slabinterval(aes(y = "right"), subguide = sg(position = "right"), n = 5) +
stat_slabinterval(aes(y = "right, just = 1"), subguide = sg(position = "right", just = 1), n = 5) +
theme_test() +
theme(plot.margin = margin(5.5,50,5.5,5.5))
)
Expand All @@ -81,9 +82,9 @@ test_that("slab subguide works with side and justification", {
sg = subguide_axis(title = "test", theme = theme_test())
vdiffr::expect_doppelganger("slab subguide with side",
p +
stat_slabinterval(aes(y = "1 bottom"), subguide = sg, side = "bottom") +
stat_slabinterval(aes(y = "2 both"), subguide = sg, side = "both") +
stat_slabinterval(aes(y = "3 top"), subguide = sg, side = "top")
stat_slabinterval(aes(y = "1 bottom"), subguide = sg, side = "bottom", n = 5) +
stat_slabinterval(aes(y = "2 both"), subguide = sg, side = "both", n = 5) +
stat_slabinterval(aes(y = "3 top"), subguide = sg, side = "top", n = 5)
)

p = df %>%
Expand All @@ -92,9 +93,9 @@ test_that("slab subguide works with side and justification", {

vdiffr::expect_doppelganger("slab subguide with side vertical",
p +
stat_slabinterval(aes(x = "1 left, just 0.5"), subguide = sg, side = "left", justification = 0.5) +
stat_slabinterval(aes(x = "2 both, just 0"), subguide = sg, side = "both", justification = 0) +
stat_slabinterval(aes(x = "3 right"), subguide = sg, side = "right")
stat_slabinterval(aes(x = "1 left, just 0.5"), subguide = sg, side = "left", justification = 0.5, n = 5) +
stat_slabinterval(aes(x = "2 both, just 0"), subguide = sg, side = "both", justification = 0, n = 5) +
stat_slabinterval(aes(x = "3 right"), subguide = sg, side = "right", n = 5)
)
})

Expand Down

0 comments on commit f230423

Please sign in to comment.