diff --git a/R/deprecated.R b/R/deprecated.R index c81a507b..c79d69b5 100644 --- a/R/deprecated.R +++ b/R/deprecated.R @@ -1,16 +1,48 @@ #' Modify a \code{\link{ggmatrix}} object by adding an \pkg{ggplot2} object to all +#' @description +#' `r lifecycle::badge("deprecated")` #' -# \lifecycle{deprecated} +#' This function allows cleaner axis labels for your plots, but is deprecated. +#' You can achieve the same effect by specifying strip's background and placement +#' properties (see Examples). +#' +#' @keywords internal #' #' @export #' @examples #' # Small function to display plots only if it's interactive #' p_ <- GGally::print_if_interactive #' +#' # Cleaner axis labels with v1_ggmatrix_theme #' p_(ggpairs(iris, 1:2) + v1_ggmatrix_theme()) -#' # move the column names to the left and bottom +#' +#' # Move the column names to the left and bottom #' p_(ggpairs(iris, 1:2, switch = "both") + v1_ggmatrix_theme()) +#' +#' # Manually specifying axis labels properties +#' p_( +#' ggpairs(iris, 1:2) + +#' theme( +#' strip.background = element_rect(fill = "white"), +#' strip.placement = "outside" +#' ) +#') +#' +#' # This way you have even more control over how the final plot looks. +#' # For example, if you want to set the background color to yellow: +#' p_( +#' ggpairs(iris, 1:2) + +#' theme( +#' strip.background = element_rect(fill = "yellow"), +#' strip.placement = "outside" +#' ) +#') v1_ggmatrix_theme <- function() { + lifecycle::deprecate_soft( + when = "2.2.2", + what = "v1_ggmatrix_theme()", + details = "This function will be removed in future releases." + ) theme( strip.background = element_rect(fill = "white"), strip.placement = "outside" diff --git a/man/v1_ggmatrix_theme.Rd b/man/v1_ggmatrix_theme.Rd index 87e8ed47..c65ebe6e 100644 --- a/man/v1_ggmatrix_theme.Rd +++ b/man/v1_ggmatrix_theme.Rd @@ -7,13 +7,38 @@ v1_ggmatrix_theme() } \description{ -Modify a \code{\link{ggmatrix}} object by adding an \pkg{ggplot2} object to all +\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}} + +This function allows cleaner axis labels for your plots, but is deprecated. +You can achieve the same effect by specifying strip's background and placement +properties (see Examples). } \examples{ # Small function to display plots only if it's interactive p_ <- GGally::print_if_interactive +# Cleaner axis labels with v1_ggmatrix_theme p_(ggpairs(iris, 1:2) + v1_ggmatrix_theme()) -# move the column names to the left and bottom + +# Move the column names to the left and bottom p_(ggpairs(iris, 1:2, switch = "both") + v1_ggmatrix_theme()) + +# Manually specifying axis labels properties +p_( + ggpairs(iris, 1:2) + + theme( + strip.background = element_rect(fill = "white"), + strip.placement = "outside" + ) +) + +# This way you have even more control over how the final plot looks. +# For example, if you want to set the background color to yellow: +p_( + ggpairs(iris, 1:2) + + theme( + strip.background = element_rect(fill = "yellow"), + strip.placement = "outside" + ) +) } diff --git a/tests/testthat/_snaps/deprecated.md b/tests/testthat/_snaps/deprecated.md new file mode 100644 index 00000000..76ba7ca1 --- /dev/null +++ b/tests/testthat/_snaps/deprecated.md @@ -0,0 +1,22 @@ +# v1_ggmatrix_theme is deprecated + + Code + v1_ggmatrix_theme() + Condition + Warning: + `v1_ggmatrix_theme()` was deprecated in GGally 2.2.2. + i This function will be removed in future releases. + Output + List of 2 + $ strip.background:List of 5 + ..$ fill : chr "white" + ..$ colour : NULL + ..$ linewidth : NULL + ..$ linetype : NULL + ..$ inherit.blank: logi FALSE + ..- attr(*, "class")= chr [1:2] "element_rect" "element" + $ strip.placement : chr "outside" + - attr(*, "class")= chr [1:2] "theme" "gg" + - attr(*, "complete")= logi FALSE + - attr(*, "validate")= logi TRUE + diff --git a/tests/testthat/test-deprecated.R b/tests/testthat/test-deprecated.R index d573db1c..eaaa9c1c 100644 --- a/tests/testthat/test-deprecated.R +++ b/tests/testthat/test-deprecated.R @@ -6,3 +6,9 @@ test_that("ggally-cor", { p <- ggally_cor_v1_5(tips, ggplot2::aes(!!as.name("total_bill"), !!as.name("tip"))) ) }) + +test_that("v1_ggmatrix_theme is deprecated", { + expect_snapshot( + v1_ggmatrix_theme() + ) +})