Skip to content

Commit

Permalink
Update v1_ggmatrix_theme deprecation warning
Browse files Browse the repository at this point in the history
  • Loading branch information
92amartins committed Apr 22, 2024
1 parent 349d440 commit abe82d8
Show file tree
Hide file tree
Showing 4 changed files with 89 additions and 4 deletions.
36 changes: 34 additions & 2 deletions R/deprecated.R
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
29 changes: 27 additions & 2 deletions man/v1_ggmatrix_theme.Rd

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

22 changes: 22 additions & 0 deletions tests/testthat/_snaps/deprecated.md
Original file line number Diff line number Diff line change
@@ -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

6 changes: 6 additions & 0 deletions tests/testthat/test-deprecated.R
Original file line number Diff line number Diff line change
Expand Up @@ -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()
)
})

0 comments on commit abe82d8

Please sign in to comment.