Skip to content

Commit 9b40bf7

Browse files
Deprecate grid_lines(size) instead of removing it
grid_lines() is exported, so we can't just drop the size parameter without breaking user code. Keep it with a lifecycle deprecation warning pointing to linewidth. Also adds lifecycle as an imported dependency and updates the test to use linewidth.
1 parent 382b825 commit 9b40bf7

6 files changed

Lines changed: 20 additions & 4 deletions

File tree

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: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -447,8 +447,17 @@ plot_bg <- function(on = TRUE, ...) {
447447
#' @rdname bayesplot-helpers
448448
#' @export
449449
#' @param color,linewidth Passed to [ggplot2::element_line()].
450-
#'
451-
grid_lines <- function(color = "gray50", linewidth = 0.2) {
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(
453462
panel.grid.major = element_line(color = color, linewidth = linewidth),
454463
panel.grid.minor = element_line(color = color, linewidth = linewidth * 0.5)

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}{

man/bayesplot-helpers.Rd

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

tests/testthat/test-convenience-functions.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ test_that("lbub works", {
6363

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

0 commit comments

Comments
 (0)