Skip to content

Commit 40fd9eb

Browse files
authored
Merge pull request #446 from ishaan-arora-1/fix/deprecated-size-and-dead-code-444-445
Remove dead modify_aes_() and fix deprecated size usage in helpers
2 parents af1a55c + 9b40bf7 commit 40fd9eb

File tree

11 files changed

+33
-24
lines changed

11 files changed

+33
-24
lines changed

DESCRIPTION

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ Imports:
3434
ggplot2 (>= 3.4.0),
3535
ggridges (>= 0.5.5),
3636
glue,
37+
lifecycle,
3738
posterior,
3839
reshape2,
3940
rlang (>= 0.3.0),

NAMESPACE

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,3 +226,6 @@ importFrom(dplyr,top_n)
226226
importFrom(dplyr,ungroup)
227227
importFrom(dplyr,vars)
228228
importFrom(ggplot2,"%+replace%")
229+
importFrom(lifecycle,deprecate_warn)
230+
importFrom(lifecycle,deprecated)
231+
importFrom(lifecycle,is_present)

R/bayesplot-helpers.R

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -446,19 +446,28 @@ plot_bg <- function(on = TRUE, ...) {
446446

447447
#' @rdname bayesplot-helpers
448448
#' @export
449-
#' @param color,size Passed to [ggplot2::element_line()].
450-
#'
451-
grid_lines <- function(color = "gray50", size = 0.2) {
449+
#' @param color,linewidth Passed to [ggplot2::element_line()].
450+
#' @param size `r lifecycle::badge("deprecated")` Use `linewidth` instead.
451+
#'
452+
grid_lines <- function(color = "gray50", linewidth = 0.2, size = deprecated()) {
453+
if (lifecycle::is_present(size)) {
454+
lifecycle::deprecate_warn(
455+
"1.16.0",
456+
"grid_lines(size)",
457+
"grid_lines(linewidth)"
458+
)
459+
linewidth <- size
460+
}
452461
theme(
453-
panel.grid.major = element_line(color = color, linewidth = size),
454-
panel.grid.minor = element_line(color = color, linewidth = size * 0.5)
462+
panel.grid.major = element_line(color = color, linewidth = linewidth),
463+
panel.grid.minor = element_line(color = color, linewidth = linewidth * 0.5)
455464
)
456465
}
457466

458-
grid_lines_y <- function(color = "gray50", size = 0.2) {
467+
grid_lines_y <- function(color = "gray50", linewidth = 0.2) {
459468
theme(
460-
panel.grid.major.y = element_line(color = color, linewidth = size),
461-
panel.grid.minor.y = element_line(color = color, linewidth = size * 0.5)
469+
panel.grid.major.y = element_line(color = color, linewidth = linewidth),
470+
panel.grid.minor.y = element_line(color = color, linewidth = linewidth * 0.5)
462471
)
463472
}
464473

R/bayesplot-package.R

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#'
66
#' @import ggplot2 stats rlang
77
#' @importFrom dplyr %>% summarise group_by select
8+
#' @importFrom lifecycle deprecated deprecate_warn is_present
89
#'
910
#' @description
1011
#' \if{html}{

R/helpers-gg.R

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,17 +24,10 @@ geom_ignore <- function(...) {
2424

2525
#' Add new aesthetic mappings to a list of aesthetic mappings
2626
#'
27-
#' @param mapping a list of `uneval` aesthetic mappings (created by `aes_()`)
28-
#' @param ... additional mappings to add, e.g., `color = ~ parameter`
27+
#' @param mapping a list of `uneval` aesthetic mappings (created by `aes()`)
28+
#' @param ... additional mappings to add using `.data$` syntax
2929
#' @return the updated list
3030
#' @noRd
31-
modify_aes_ <- function(mapping, ...) {
32-
utils::modifyList(mapping, aes_(...))
33-
}
34-
35-
#' Same as `modify_aes_` but using `aes()` instead of `aes_()` (now deprecated).
36-
#' Often `...` will need to contain expression of the form `.data$x` to avoid R cmd check warnings
37-
#' @noRd
3831
modify_aes <- function(mapping, ...) {
3932
utils::modifyList(mapping, aes(...))
4033
}

R/mcmc-diagnostics.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@
7777
#' (p <- mcmc_acf_bar(x, pars = c("alpha", "beta[1]")))
7878
#'
7979
#' # add horiztonal dashed line at 0.5
80-
#' p + hline_at(0.5, linetype = 2, size = 0.15, color = "gray")
80+
#' p + hline_at(0.5, linetype = 2, linewidth = 0.15, color = "gray")
8181
#' }
8282
#'
8383
#' # fake rhat values to use for demonstration

R/mcmc-scatterplots.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@
109109
#' color_scheme_set("pink")
110110
#' (p3 <- mcmc_scatter(x, pars = c("alpha", "beta[3]"), alpha = 0.25, size = 3))
111111
#' p3 + geom_smooth(method = "lm", se = FALSE, color = "gray20",
112-
#' size = .75, linetype = 2)
112+
#' linewidth = .75, linetype = 2)
113113
#'
114114
#' \donttest{
115115
#' if (requireNamespace("hexbin", quietly = TRUE)) {

man/MCMC-diagnostics.Rd

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/MCMC-scatterplots.Rd

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/bayesplot-helpers.Rd

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

0 commit comments

Comments
 (0)