Skip to content

Commit 1665053

Browse files
committed
add alpha argument to mcmc_hist and mcmc_dens
1 parent 52f1a9f commit 1665053

File tree

2 files changed

+23
-8
lines changed

2 files changed

+23
-8
lines changed

R/mcmc-distributions.R

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#' @template args-transformations
1313
#' @template args-facet_args
1414
#' @param ... Currently ignored.
15+
#' @param alpha Passed to the geom to control the transparency.
1516
#'
1617
#' @template return-ggplot
1718
#'
@@ -113,7 +114,8 @@ mcmc_hist <- function(x,
113114
facet_args = list(),
114115
binwidth = NULL,
115116
breaks = NULL,
116-
freq = TRUE) {
117+
freq = TRUE,
118+
alpha = 1) {
117119
check_ignored_arguments(...)
118120
.mcmc_hist(
119121
x,
@@ -125,6 +127,7 @@ mcmc_hist <- function(x,
125127
breaks = breaks,
126128
by_chain = FALSE,
127129
freq = freq,
130+
alpha = alpha,
128131
...
129132
)
130133
}
@@ -137,7 +140,8 @@ mcmc_dens <- function(x,
137140
transformations = list(),
138141
...,
139142
facet_args = list(),
140-
trim = FALSE) {
143+
trim = FALSE,
144+
alpha = 1) {
141145
check_ignored_arguments(...)
142146
.mcmc_dens(
143147
x,
@@ -147,6 +151,7 @@ mcmc_dens <- function(x,
147151
facet_args = facet_args,
148152
by_chain = FALSE,
149153
trim = trim,
154+
alpha = alpha,
150155
...
151156
)
152157
}
@@ -161,7 +166,8 @@ mcmc_hist_by_chain <- function(x,
161166
...,
162167
facet_args = list(),
163168
binwidth = NULL,
164-
freq = TRUE) {
169+
freq = TRUE,
170+
alpha = 1) {
165171
check_ignored_arguments(...)
166172
.mcmc_hist(
167173
x,
@@ -172,6 +178,7 @@ mcmc_hist_by_chain <- function(x,
172178
binwidth = binwidth,
173179
by_chain = TRUE,
174180
freq = freq,
181+
alpha = alpha,
175182
...
176183
)
177184
}
@@ -312,6 +319,7 @@ mcmc_violin <- function(x,
312319
breaks = NULL,
313320
by_chain = FALSE,
314321
freq = TRUE,
322+
alpha = 1,
315323
...) {
316324
x <- prepare_mcmc_array(x, pars, regex_pars, transformations)
317325

@@ -330,7 +338,8 @@ mcmc_violin <- function(x,
330338
size = .25,
331339
na.rm = TRUE,
332340
binwidth = binwidth,
333-
breaks = breaks
341+
breaks = breaks,
342+
alpha = alpha
334343
)
335344

336345
facet_args[["scales"]] <- facet_args[["scales"]] %||% "free"
@@ -373,6 +382,7 @@ mcmc_violin <- function(x,
373382
geom = c("density", "violin"),
374383
probs = c(0.1, 0.5, 0.9),
375384
trim = FALSE,
385+
alpha = 1,
376386
...) {
377387
x <- prepare_mcmc_array(x, pars, regex_pars, transformations)
378388
data <- melt_mcmc(x)
@@ -396,7 +406,7 @@ mcmc_violin <- function(x,
396406
} else {
397407
list(x = ~ Value)
398408
}
399-
geom_args <- list(size = 0.5, na.rm = TRUE)
409+
geom_args <- list(size = 0.5, na.rm = TRUE, alpha = alpha)
400410
if (violin) {
401411
geom_args[["draw_quantiles"]] <- probs
402412
} else {

man/MCMC-distributions.Rd

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

0 commit comments

Comments
 (0)