Skip to content

Commit e908354

Browse files
committed
make compatible with using less vertical blank space
1 parent 897b4b3 commit e908354

25 files changed

+1813
-31
lines changed

NEWS.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,8 @@
77

88
* `mcmc_hist()` and `mcmc_dens()` gain argument `alpha` for controlling transparency. (#244)
99

10-
* Size of points and interval lines can set in
11-
`mcmc_intervals(..., outer_size, inner_size, point_size)`. (#215, #228, #229)
12-
10+
* `mcmc_areas()` and `mcmc_areas_ridges()` gain an argument `border_size` for
11+
controlling the thickness of the ridgelines. (#224)
1312

1413
# bayesplot 1.8.1
1514

R/mcmc-intervals.R

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,8 @@
7979
#' pars = c("alpha", "beta[4]"),
8080
#' prob = 2/3,
8181
#' prob_outer = 0.9,
82-
#' point_est = "mean"
82+
#' point_est = "mean",
83+
#' border_size = 1.5 # make the ridgelines fatter
8384
#' )
8485
#' plot(p)
8586
#'
@@ -176,7 +177,7 @@
176177
#' # Example of hierarchically related parameters
177178
#' # plotted with ridgelines
178179
#' m <- shinystan::eight_schools@posterior_sample
179-
#' mcmc_areas_ridges(m, pars = "mu", regex_pars = "theta") +
180+
#' mcmc_areas_ridges(m, pars = "mu", regex_pars = "theta", border_size = 0.75) +
180181
#' ggtitle("Treatment effect on eight schools (Rubin, 1981)")
181182
#' }
182183
#'
@@ -281,8 +282,8 @@ mcmc_intervals <- function(x,
281282

282283
#' @rdname MCMC-intervals
283284
#' @export
284-
#' @param size For `mcmc_areas()` and `mcmc_areas_ridges()`, the size of the
285-
#' ridgelines.
285+
#' @param border_size For `mcmc_areas()` and `mcmc_areas_ridges()`, the size of
286+
#' the ridgelines.
286287
mcmc_areas <- function(x,
287288
pars = character(),
288289
regex_pars = character(),
@@ -293,7 +294,7 @@ mcmc_areas <- function(x,
293294
prob_outer = 1,
294295
point_est = c("median", "mean", "none"),
295296
rhat = numeric(),
296-
size = NULL,
297+
border_size = NULL,
297298
bw = NULL,
298299
adjust = NULL,
299300
kernel = NULL,
@@ -374,10 +375,10 @@ mcmc_areas <- function(x,
374375
fill = NA
375376
)
376377

377-
if (!is.null(size)) {
378-
args_bottom$size <- size
379-
args_outer$size <- size
380-
args_inner$size <- size
378+
if (!is.null(border_size)) {
379+
args_bottom$size <- border_size
380+
args_outer$size <- border_size
381+
args_inner$size <- border_size
381382
}
382383

383384
if (color_by_rhat) {
@@ -441,8 +442,8 @@ mcmc_areas <- function(x,
441442
scale_y_discrete(
442443
limits = unique(rev(data$parameter)),
443444
expand = expansion(
444-
add = c(0, .5 + 1/(2 * nlevels(data$parameter))),
445-
mult = c(.1, .1)
445+
add = c(0, 0.5 + 1/(2 * nlevels(data$parameter))),
446+
mult = c(0.05, 1/(2 * nlevels(data$parameter)))
446447
)
447448
) +
448449
xlim(x_lim) +
@@ -463,7 +464,7 @@ mcmc_areas_ridges <- function(x,
463464
...,
464465
prob_outer = 1,
465466
prob = 1,
466-
size = NULL,
467+
border_size = NULL,
467468
bw = NULL, adjust = NULL, kernel = NULL,
468469
n_dens = NULL) {
469470
check_ignored_arguments(...)
@@ -494,8 +495,8 @@ mcmc_areas_ridges <- function(x,
494495
fill = NA,
495496
stat = "identity"
496497
)
497-
if (!is.null(size)) {
498-
args_outer$size <- size
498+
if (!is.null(border_size)) {
499+
args_outer$size <- border_size
499500
}
500501

501502
layer_outer <- do.call(ggridges::geom_density_ridges, args_outer)
@@ -535,8 +536,8 @@ mcmc_areas_ridges <- function(x,
535536
scale = scale,
536537
stat = "identity")
537538

538-
if (!is.null(size)) {
539-
args_inner$size <- size
539+
if (!is.null(border_size)) {
540+
args_inner$size <- border_size
540541
}
541542

542543
layer_list_inner[[par_num]] <- do.call(ggridges::geom_ridgeline, args_inner)
@@ -547,8 +548,8 @@ mcmc_areas_ridges <- function(x,
547548
layer_outer +
548549
scale_y_discrete(limits = unique(rev(data$parameter)),
549550
expand = expansion(
550-
add = c(0, 1 + 1/(2 * nlevels(data$parameter))),
551-
mult = c(.1, .1)
551+
add = c(0, 1.4 + 1/(2 * nlevels(data$parameter))),
552+
mult = c(0.05, 1/(2 * nlevels(data$parameter)))
552553
)) +
553554
layer_list_inner +
554555
layer_vertical_line +

man/MCMC-distributions.Rd

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/MCMC-intervals.Rd

Lines changed: 7 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/testthat/_snaps/mcmc-intervals/mcmc-areas-default.svg

Lines changed: 98 additions & 0 deletions
Loading

tests/testthat/_snaps/mcmc-intervals/mcmc-areas-equal-height.svg

Lines changed: 98 additions & 0 deletions
Loading

tests/testthat/_snaps/mcmc-intervals/mcmc-areas-inner.svg

Lines changed: 98 additions & 0 deletions
Loading

tests/testthat/_snaps/mcmc-intervals/mcmc-areas-means.svg

Lines changed: 98 additions & 0 deletions
Loading

tests/testthat/_snaps/mcmc-intervals/mcmc-areas-no-points.svg

Lines changed: 88 additions & 0 deletions
Loading

tests/testthat/_snaps/mcmc-intervals/mcmc-areas-outer.svg

Lines changed: 96 additions & 0 deletions
Loading

0 commit comments

Comments
 (0)