Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ Imports:
ggplot2 (>= 3.4.0),
ggridges (>= 0.5.5),
glue,
lifecycle,
posterior,
reshape2,
rlang (>= 0.3.0),
Expand Down
3 changes: 3 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -226,3 +226,6 @@ importFrom(dplyr,top_n)
importFrom(dplyr,ungroup)
importFrom(dplyr,vars)
importFrom(ggplot2,"%+replace%")
importFrom(lifecycle,deprecate_warn)
importFrom(lifecycle,deprecated)
importFrom(lifecycle,is_present)
25 changes: 17 additions & 8 deletions R/bayesplot-helpers.R
Original file line number Diff line number Diff line change
Expand Up @@ -446,19 +446,28 @@ plot_bg <- function(on = TRUE, ...) {

#' @rdname bayesplot-helpers
#' @export
#' @param color,size Passed to [ggplot2::element_line()].
#'
grid_lines <- function(color = "gray50", size = 0.2) {
#' @param color,linewidth Passed to [ggplot2::element_line()].
#' @param size `r lifecycle::badge("deprecated")` Use `linewidth` instead.
#'
grid_lines <- function(color = "gray50", linewidth = 0.2, size = deprecated()) {
if (lifecycle::is_present(size)) {
lifecycle::deprecate_warn(
"1.16.0",
"grid_lines(size)",
"grid_lines(linewidth)"
)
linewidth <- size
}
theme(
panel.grid.major = element_line(color = color, linewidth = size),
panel.grid.minor = element_line(color = color, linewidth = size * 0.5)
panel.grid.major = element_line(color = color, linewidth = linewidth),
panel.grid.minor = element_line(color = color, linewidth = linewidth * 0.5)
)
}

grid_lines_y <- function(color = "gray50", size = 0.2) {
grid_lines_y <- function(color = "gray50", linewidth = 0.2) {
theme(
panel.grid.major.y = element_line(color = color, linewidth = size),
panel.grid.minor.y = element_line(color = color, linewidth = size * 0.5)
panel.grid.major.y = element_line(color = color, linewidth = linewidth),
panel.grid.minor.y = element_line(color = color, linewidth = linewidth * 0.5)
)
}

Expand Down
1 change: 1 addition & 0 deletions R/bayesplot-package.R
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#'
#' @import ggplot2 stats rlang
#' @importFrom dplyr %>% summarise group_by select
#' @importFrom lifecycle deprecated deprecate_warn is_present
#'
#' @description
#' \if{html}{
Expand Down
11 changes: 2 additions & 9 deletions R/helpers-gg.R
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,10 @@ geom_ignore <- function(...) {

#' Add new aesthetic mappings to a list of aesthetic mappings
#'
#' @param mapping a list of `uneval` aesthetic mappings (created by `aes_()`)
#' @param ... additional mappings to add, e.g., `color = ~ parameter`
#' @param mapping a list of `uneval` aesthetic mappings (created by `aes()`)
#' @param ... additional mappings to add using `.data$` syntax
#' @return the updated list
#' @noRd
modify_aes_ <- function(mapping, ...) {
utils::modifyList(mapping, aes_(...))
}

#' Same as `modify_aes_` but using `aes()` instead of `aes_()` (now deprecated).
#' Often `...` will need to contain expression of the form `.data$x` to avoid R cmd check warnings
#' @noRd
modify_aes <- function(mapping, ...) {
utils::modifyList(mapping, aes(...))
}
Expand Down
2 changes: 1 addition & 1 deletion R/mcmc-diagnostics.R
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@
#' (p <- mcmc_acf_bar(x, pars = c("alpha", "beta[1]")))
#'
#' # add horiztonal dashed line at 0.5
#' p + hline_at(0.5, linetype = 2, size = 0.15, color = "gray")
#' p + hline_at(0.5, linetype = 2, linewidth = 0.15, color = "gray")
#' }
#'
#' # fake rhat values to use for demonstration
Expand Down
2 changes: 1 addition & 1 deletion R/mcmc-scatterplots.R
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@
#' color_scheme_set("pink")
#' (p3 <- mcmc_scatter(x, pars = c("alpha", "beta[3]"), alpha = 0.25, size = 3))
#' p3 + geom_smooth(method = "lm", se = FALSE, color = "gray20",
#' size = .75, linetype = 2)
#' linewidth = .75, linetype = 2)
#'
#' \donttest{
#' if (requireNamespace("hexbin", quietly = TRUE)) {
Expand Down
2 changes: 1 addition & 1 deletion man/MCMC-diagnostics.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/MCMC-scatterplots.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 4 additions & 2 deletions man/bayesplot-helpers.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion tests/testthat/test-convenience-functions.R
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ test_that("lbub works", {

# plot and facet backgrounds ----------------------------------------------
test_that("grid_lines returns correct theme object", {
thm <- theme_default() + grid_lines(size = 1.5, color = "purple")
thm <- theme_default() + grid_lines(linewidth = 1.5, color = "purple")
expect_equal(thm$panel.grid.major, element_line(linewidth = 1.5, color = "purple"))
expect_equal(thm$panel.grid.minor, element_line(linewidth = 0.75, color = "purple"))
})
Expand Down
Loading