From 09b9020c9f7c7a9774324e2a90e78569b85d7780 Mon Sep 17 00:00:00 2001 From: Teun van den Brand Date: Wed, 7 May 2025 08:57:03 +0200 Subject: [PATCH 1/9] Use `coord_radial()` in examples --- R/coord-polar.R | 15 ++++++++------- man/coord_polar.Rd | 15 ++++++++------- 2 files changed, 16 insertions(+), 14 deletions(-) diff --git a/R/coord-polar.R b/R/coord-polar.R index b8855f52b9..02ab9a4a94 100644 --- a/R/coord-polar.R +++ b/R/coord-polar.R @@ -23,19 +23,19 @@ #' # A pie chart = stacked bar chart + polar coordinates #' pie <- ggplot(mtcars, aes(x = factor(1), fill = factor(cyl))) + #' geom_bar(width = 1) -#' pie + coord_polar(theta = "y") +#' pie + coord_radial(theta = "y", expand = FALSE) #' #' \donttest{ #' #' # A coxcomb plot = bar chart + polar coordinates #' cxc <- ggplot(mtcars, aes(x = factor(cyl))) + #' geom_bar(width = 1, colour = "black") -#' cxc + coord_polar() +#' cxc + coord_radial(expand = FALSE) #' # A new type of plot? -#' cxc + coord_polar(theta = "y") +#' cxc + coord_radial(theta = "y", expand = FALSE) #' #' # The bullseye chart -#' pie + coord_polar() +#' pie + coord_radial(expand = FALSE) #' #' # Hadley's favourite pie chart #' df <- data.frame( @@ -45,7 +45,7 @@ #' ggplot(df, aes(x = "", y = value, fill = variable)) + #' geom_col(width = 1) + #' scale_fill_manual(values = c("red", "yellow")) + -#' coord_polar("y", start = pi / 3) + +#' coord_radial("y", start = pi / 3, expand = FALSE) + #' labs(title = "Pac man") #' #' # Windrose + doughnut plot @@ -56,9 +56,10 @@ #' doh <- ggplot(movies, aes(x = rrating, fill = budgetq)) #' #' # Wind rose -#' doh + geom_bar(width = 1) + coord_polar() +#' doh + geom_bar(width = 1) + coord_radial(expand = FALSE) #' # Race track plot -#' doh + geom_bar(width = 0.9, position = "fill") + coord_polar(theta = "y") +#' doh + geom_bar(width = 0.9, position = "fill") + +#' coord_radial(theta = "y", expand = FALSE) #' } #' } coord_polar <- function(theta = "x", start = 0, direction = 1, clip = "on") { diff --git a/man/coord_polar.Rd b/man/coord_polar.Rd index 3bc579bcbc..b11499074d 100644 --- a/man/coord_polar.Rd +++ b/man/coord_polar.Rd @@ -93,19 +93,19 @@ sensible when \code{inner.radius > 0}. # A pie chart = stacked bar chart + polar coordinates pie <- ggplot(mtcars, aes(x = factor(1), fill = factor(cyl))) + geom_bar(width = 1) -pie + coord_polar(theta = "y") +pie + coord_radial(theta = "y", expand = FALSE) \donttest{ # A coxcomb plot = bar chart + polar coordinates cxc <- ggplot(mtcars, aes(x = factor(cyl))) + geom_bar(width = 1, colour = "black") -cxc + coord_polar() +cxc + coord_radial(expand = FALSE) # A new type of plot? -cxc + coord_polar(theta = "y") +cxc + coord_radial(theta = "y", expand = FALSE) # The bullseye chart -pie + coord_polar() +pie + coord_radial(expand = FALSE) # Hadley's favourite pie chart df <- data.frame( @@ -115,7 +115,7 @@ df <- data.frame( ggplot(df, aes(x = "", y = value, fill = variable)) + geom_col(width = 1) + scale_fill_manual(values = c("red", "yellow")) + - coord_polar("y", start = pi / 3) + + coord_radial("y", start = pi / 3, expand = FALSE) + labs(title = "Pac man") # Windrose + doughnut plot @@ -126,9 +126,10 @@ movies$budgetq <- cut_number(movies$budget, 4) doh <- ggplot(movies, aes(x = rrating, fill = budgetq)) # Wind rose -doh + geom_bar(width = 1) + coord_polar() +doh + geom_bar(width = 1) + coord_radial(expand = FALSE) # Race track plot -doh + geom_bar(width = 0.9, position = "fill") + coord_polar(theta = "y") +doh + geom_bar(width = 0.9, position = "fill") + + coord_radial(theta = "y", expand = FALSE) } } # A partial polar plot From b66184876f602121d147469b82fc49985337859a Mon Sep 17 00:00:00 2001 From: Teun van den Brand Date: Wed, 7 May 2025 08:59:42 +0200 Subject: [PATCH 2/9] move and merge docs to `coord_radial()` --- R/coord-polar.R | 64 +---------------------- R/coord-radial.R | 68 +++++++++++++++++++++++-- man/{coord_polar.Rd => coord_radial.Rd} | 0 3 files changed, 64 insertions(+), 68 deletions(-) rename man/{coord_polar.Rd => coord_radial.Rd} (100%) diff --git a/R/coord-polar.R b/R/coord-polar.R index 02ab9a4a94..d1a4bf2ad9 100644 --- a/R/coord-polar.R +++ b/R/coord-polar.R @@ -1,67 +1,5 @@ -#' Polar coordinates -#' -#' The polar coordinate system is most commonly used for pie charts, which -#' are a stacked bar chart in polar coordinates. `coord_radial()` has extended -#' options. -#' -#' @param theta variable to map angle to (`x` or `y`) -#' @param start Offset of starting point from 12 o'clock in radians. Offset -#' is applied clockwise or anticlockwise depending on value of `direction`. -#' @param direction 1, clockwise; -1, anticlockwise -#' @param clip Should drawing be clipped to the extent of the plot panel? A -#' setting of `"on"` (the default) means yes, and a setting of `"off"` -#' means no. For details, please see [`coord_cartesian()`]. +#' @rdname coord_radial #' @export -#' @seealso -#' The `r link_book("polar coordinates section", "coord#polar-coordinates-with-coord_polar")` -#' @examples -#' # NOTE: Use these plots with caution - polar coordinates has -#' # major perceptual problems. The main point of these examples is -#' # to demonstrate how these common plots can be described in the -#' # grammar. Use with EXTREME caution. -#' -#' # A pie chart = stacked bar chart + polar coordinates -#' pie <- ggplot(mtcars, aes(x = factor(1), fill = factor(cyl))) + -#' geom_bar(width = 1) -#' pie + coord_radial(theta = "y", expand = FALSE) -#' -#' \donttest{ -#' -#' # A coxcomb plot = bar chart + polar coordinates -#' cxc <- ggplot(mtcars, aes(x = factor(cyl))) + -#' geom_bar(width = 1, colour = "black") -#' cxc + coord_radial(expand = FALSE) -#' # A new type of plot? -#' cxc + coord_radial(theta = "y", expand = FALSE) -#' -#' # The bullseye chart -#' pie + coord_radial(expand = FALSE) -#' -#' # Hadley's favourite pie chart -#' df <- data.frame( -#' variable = c("does not resemble", "resembles"), -#' value = c(20, 80) -#' ) -#' ggplot(df, aes(x = "", y = value, fill = variable)) + -#' geom_col(width = 1) + -#' scale_fill_manual(values = c("red", "yellow")) + -#' coord_radial("y", start = pi / 3, expand = FALSE) + -#' labs(title = "Pac man") -#' -#' # Windrose + doughnut plot -#' if (require("ggplot2movies")) { -#' movies$rrating <- cut_interval(movies$rating, length = 1) -#' movies$budgetq <- cut_number(movies$budget, 4) -#' -#' doh <- ggplot(movies, aes(x = rrating, fill = budgetq)) -#' -#' # Wind rose -#' doh + geom_bar(width = 1) + coord_radial(expand = FALSE) -#' # Race track plot -#' doh + geom_bar(width = 0.9, position = "fill") + -#' coord_radial(theta = "y", expand = FALSE) -#' } -#' } coord_polar <- function(theta = "x", start = 0, direction = 1, clip = "on") { theta <- arg_match0(theta, c("x", "y")) r <- if (theta == "x") "y" else "x" diff --git a/R/coord-radial.R b/R/coord-radial.R index 3cef9c2b5b..f2a14b4bc1 100644 --- a/R/coord-radial.R +++ b/R/coord-radial.R @@ -1,6 +1,16 @@ - -#' @rdname coord_polar +#' Polar coordinates +#' +#' The polar coordinate system is most commonly used for pie charts, which +#' are a stacked bar chart in polar coordinates. `coord_radial()` has extended +#' options. #' +#' @param theta variable to map angle to (`x` or `y`) +#' @param start Offset of starting point from 12 o'clock in radians. Offset +#' is applied clockwise or anticlockwise depending on value of `direction`. +#' @param direction 1, clockwise; -1, anticlockwise +#' @param clip Should drawing be clipped to the extent of the plot panel? A +#' setting of `"on"` (the default) means yes, and a setting of `"off"` +#' means no. For details, please see [`coord_cartesian()`]. #' @param end Position from 12 o'clock in radians where plot ends, to allow #' for partial polar coordinates. The default, `NULL`, is set to #' `start + 2 * pi`. @@ -26,7 +36,7 @@ #' (default) keep directions as is. `"theta"` reverses the angle and `"r"` #' reverses the radius. `"thetar"` reverses both the angle and the radius. #' @param r_axis_inside,rotate_angle `r lifecycle::badge("deprecated")` -#' +#' @export #' @note #' In `coord_radial()`, position guides can be defined by using #' `guides(r = ..., theta = ..., r.sec = ..., theta.sec = ...)`. Note that @@ -35,8 +45,56 @@ #' be used for the `theta` positions. Using the `theta.sec` position is only #' sensible when `inner.radius > 0`. #' -#' @export +#' @seealso +#' The `r link_book("polar coordinates section", "coord#polar-coordinates-with-coord_polar")` #' @examples +#' # NOTE: Use these plots with caution - polar coordinates has +#' # major perceptual problems. The main point of these examples is +#' # to demonstrate how these common plots can be described in the +#' # grammar. Use with EXTREME caution. +#' +#' # A pie chart = stacked bar chart + polar coordinates +#' pie <- ggplot(mtcars, aes(x = factor(1), fill = factor(cyl))) + +#' geom_bar(width = 1) +#' pie + coord_radial(theta = "y", expand = FALSE) +#' +#' \donttest{ +#' +#' # A coxcomb plot = bar chart + polar coordinates +#' cxc <- ggplot(mtcars, aes(x = factor(cyl))) + +#' geom_bar(width = 1, colour = "black") +#' cxc + coord_radial(expand = FALSE) +#' # A new type of plot? +#' cxc + coord_radial(theta = "y", expand = FALSE) +#' +#' # The bullseye chart +#' pie + coord_radial(expand = FALSE) +#' +#' # Hadley's favourite pie chart +#' df <- data.frame( +#' variable = c("does not resemble", "resembles"), +#' value = c(20, 80) +#' ) +#' ggplot(df, aes(x = "", y = value, fill = variable)) + +#' geom_col(width = 1) + +#' scale_fill_manual(values = c("red", "yellow")) + +#' coord_radial("y", start = pi / 3, expand = FALSE) + +#' labs(title = "Pac man") +#' +#' # Windrose + doughnut plot +#' if (require("ggplot2movies")) { +#' movies$rrating <- cut_interval(movies$rating, length = 1) +#' movies$budgetq <- cut_number(movies$budget, 4) +#' +#' doh <- ggplot(movies, aes(x = rrating, fill = budgetq)) +#' +#' # Wind rose +#' doh + geom_bar(width = 1) + coord_radial(expand = FALSE) +#' # Race track plot +#' doh + geom_bar(width = 0.9, position = "fill") + +#' coord_radial(theta = "y", expand = FALSE) +#' } +#' } #' # A partial polar plot #' ggplot(mtcars, aes(disp, mpg)) + #' geom_point() + @@ -475,7 +533,7 @@ CoordRadial <- ggproto("CoordRadial", Coord, } ) -view_scales_polar <- function(scale, theta = "x", coord_limits = NULL, +view_scales_polar <- function(scale, theta = "x", coord_limits = NULL, expand = TRUE) { aesthetic <- scale$aesthetics[1] diff --git a/man/coord_polar.Rd b/man/coord_radial.Rd similarity index 100% rename from man/coord_polar.Rd rename to man/coord_radial.Rd From f992f88b8746ee88f7931ddbb540f910d73c601a Mon Sep 17 00:00:00 2001 From: Teun van den Brand Date: Wed, 7 May 2025 09:05:04 +0200 Subject: [PATCH 3/9] slap a superseded badge on `coord_polar()` --- R/coord-radial.R | 5 +++-- man/coord_radial.Rd | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/R/coord-radial.R b/R/coord-radial.R index f2a14b4bc1..dc3b1abf21 100644 --- a/R/coord-radial.R +++ b/R/coord-radial.R @@ -1,8 +1,9 @@ #' Polar coordinates #' #' The polar coordinate system is most commonly used for pie charts, which -#' are a stacked bar chart in polar coordinates. `coord_radial()` has extended -#' options. +#' are a stacked bar chart in polar coordinates. \cr +#' `r lifecycle::badge("superseded")`: `coord_polar()` has been in favour of +#' `coord_radial()`. #' #' @param theta variable to map angle to (`x` or `y`) #' @param start Offset of starting point from 12 o'clock in radians. Offset diff --git a/man/coord_radial.Rd b/man/coord_radial.Rd index b11499074d..a3678cc13f 100644 --- a/man/coord_radial.Rd +++ b/man/coord_radial.Rd @@ -73,8 +73,9 @@ reverses the radius. \code{"thetar"} reverses both the angle and the radius.} } \description{ The polar coordinate system is most commonly used for pie charts, which -are a stacked bar chart in polar coordinates. \code{coord_radial()} has extended -options. +are a stacked bar chart in polar coordinates. \cr +\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#superseded}{\figure{lifecycle-superseded.svg}{options: alt='[Superseded]'}}}{\strong{[Superseded]}}: \code{coord_polar()} has been in favour of +\code{coord_radial()}. } \note{ In \code{coord_radial()}, position guides can be defined by using From cc8a16ce6fb399106b1c6d3cd7f6f15e1afaaaaf Mon Sep 17 00:00:00 2001 From: Teun van den Brand Date: Wed, 7 May 2025 09:23:45 +0200 Subject: [PATCH 4/9] supersede `expand_limits()` --- R/limits.R | 3 +++ man/expand_limits.Rd | 3 +++ 2 files changed, 6 insertions(+) diff --git a/R/limits.R b/R/limits.R index 57f2465018..c13cd196f9 100644 --- a/R/limits.R +++ b/R/limits.R @@ -159,6 +159,9 @@ limits.POSIXlt <- function(lims, var, call = caller_env()) { #' Expand the plot limits, using data #' +#' `r lifecycle::badge("superseded")`: It is recommended to pass a function to +#' the `limits` argument in scales instead. For example: +#' `scale_x_continuous(limits = ~range(.x, 0))` to include zero.\cr\cr #' Sometimes you may want to ensure limits include a single value, for all #' panels or all plots. This function is a thin wrapper around #' [geom_blank()] that makes it easy to add such values. diff --git a/man/expand_limits.Rd b/man/expand_limits.Rd index 5ee0b35141..6248c3c2e4 100644 --- a/man/expand_limits.Rd +++ b/man/expand_limits.Rd @@ -11,6 +11,9 @@ expand_limits(...) should be included in each scale.} } \description{ +\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#superseded}{\figure{lifecycle-superseded.svg}{options: alt='[Superseded]'}}}{\strong{[Superseded]}}: It is recommended to pass a function to +the \code{limits} argument in scales instead. For example: +\code{scale_x_continuous(limits = ~range(.x, 0))} to include zero.\cr\cr Sometimes you may want to ensure limits include a single value, for all panels or all plots. This function is a thin wrapper around \code{\link[=geom_blank]{geom_blank()}} that makes it easy to add such values. From f7450984296dc232d7a908344891fbae182bc2f0 Mon Sep 17 00:00:00 2001 From: Teun van den Brand Date: Wed, 7 May 2025 09:30:53 +0200 Subject: [PATCH 5/9] sprinkle `signal_stage("superseded")` all over --- R/annotation-logticks.R | 2 ++ R/coord-flip.R | 1 + R/coord-map.R | 2 +- R/coord-polar.R | 1 + R/limits.R | 2 ++ 5 files changed, 7 insertions(+), 1 deletion(-) diff --git a/R/annotation-logticks.R b/R/annotation-logticks.R index 600bd6ce7c..8ff3a73056 100644 --- a/R/annotation-logticks.R +++ b/R/annotation-logticks.R @@ -93,6 +93,8 @@ annotation_logticks <- function(base = 10, sides = "bl", outside = FALSE, scaled if (!is.null(color)) colour <- color + lifecycle::signal_stage("superseded", "annotation_logticks()", "guide_axis_logticks()") + if (lifecycle::is_present(size)) { deprecate_soft0("3.5.0", I("Using the `size` aesthetic in this geom"), I("`linewidth`")) linewidth <- linewidth %||% size diff --git a/R/coord-flip.R b/R/coord-flip.R index 502ff56f88..df4cad8faf 100644 --- a/R/coord-flip.R +++ b/R/coord-flip.R @@ -57,6 +57,7 @@ #' geom_area() + #' coord_flip() coord_flip <- function(xlim = NULL, ylim = NULL, expand = TRUE, clip = "on") { + lifecycle::signal_stage("superseded", "coord_flip()") check_coord_limits(xlim) check_coord_limits(ylim) ggproto(NULL, CoordFlip, diff --git a/R/coord-map.R b/R/coord-map.R index 3ba9260206..0b18b5ce7a 100644 --- a/R/coord-map.R +++ b/R/coord-map.R @@ -136,7 +136,7 @@ coord_map <- function(projection="mercator", ..., parameters = NULL, orientation } else { params <- parameters } - + lifecycle::signal_stage("superseded", "coord_map()", "coord_sf()") check_coord_limits(xlim) check_coord_limits(ylim) diff --git a/R/coord-polar.R b/R/coord-polar.R index d1a4bf2ad9..81fd137c6d 100644 --- a/R/coord-polar.R +++ b/R/coord-polar.R @@ -3,6 +3,7 @@ coord_polar <- function(theta = "x", start = 0, direction = 1, clip = "on") { theta <- arg_match0(theta, c("x", "y")) r <- if (theta == "x") "y" else "x" + lifecycle::signal_stage("superseded", "coord_polar()", "coord_radial()") ggproto(NULL, CoordPolar, theta = theta, diff --git a/R/limits.R b/R/limits.R index c13cd196f9..976307a467 100644 --- a/R/limits.R +++ b/R/limits.R @@ -184,6 +184,8 @@ limits.POSIXlt <- function(lims, var, call = caller_env()) { expand_limits <- function(...) { data <- list2(...) + lifecycle::signal_stage("superseded", "expand_limits()") + # unpack data frame columns data_dfs <- vapply(data, is.data.frame, logical(1)) data <- unlist(c(list(data[!data_dfs]), data[data_dfs]), recursive = FALSE) From 192973be53f41cd76611caa8673597b18a9d0ad7 Mon Sep 17 00:00:00 2001 From: Teun van den Brand Date: Wed, 7 May 2025 09:43:21 +0200 Subject: [PATCH 6/9] mark `type` argument as superseded --- R/scale-colour.R | 32 ++++++++++++-------------------- man/scale_colour_continuous.Rd | 24 ++++++++---------------- man/scale_colour_discrete.Rd | 8 ++++---- 3 files changed, 24 insertions(+), 40 deletions(-) diff --git a/R/scale-colour.R b/R/scale-colour.R index c8c468559f..2580e57211 100644 --- a/R/scale-colour.R +++ b/R/scale-colour.R @@ -7,21 +7,13 @@ #' functions that assign discrete color bins to the continuous values #' instead of using a continuous color spectrum. #' -#' All these colour scales use the [options()] mechanism to determine -#' default settings. Continuous colour scales default to the values of the -#' `ggplot2.continuous.colour` and `ggplot2.continuous.fill` options, and -#' binned colour scales default to the values of the `ggplot2.binned.colour` -#' and `ggplot2.binned.fill` options. These option values default to -#' `"gradient"`, which means that the scale functions actually used are -#' [scale_colour_gradient()]/[scale_fill_gradient()] for continuous scales and -#' [scale_colour_steps()]/[scale_fill_steps()] for binned scales. -#' Alternative option values are `"viridis"` or a different scale function. -#' See description of the `type` argument for details. -#' -#' Note that the binned colour scales will use the settings of -#' `ggplot2.continuous.colour` and `ggplot2.continuous.fill` as fallback, -#' respectively, if `ggplot2.binned.colour` or `ggplot2.binned.fill` are -#' not set. +#' `r lifecycle::badge("superseded")`: The mechanism of setting defaults via +#' [options()] is superseded by theme settings. The preferred method to change +#' the default palette of scales is via the theme, for example: +#' `theme(palette.colour.continuous = scales::pal_viridis())`. The +#' `ggplot2.continuous.colour` and `ggplot2.continuous.fill` options could be +#' used to set default continuous scales and `ggplot2.binned.colour` and +#' `ggplot2.binned.fill` options to set default binned scales. #' #' These scale functions are meant to provide simple defaults. If #' you want to manually set the colors of a scale, consider using @@ -35,7 +27,7 @@ #' * a palette function that when called with a numeric vector with values #' between 0 and 1 returns the corresponding output values. #' @param ... Additional parameters passed on to the scale type -#' @param type One of the following: +#' @param type `r lifecycle::badge("superseded")` One of the following: #' * "gradient" (the default) #' * "viridis" #' * A function that returns a continuous colour scale. @@ -173,9 +165,7 @@ scale_fill_binned <- function(..., palette = NULL, aesthetics = "fill", guide = #' Discrete colour scales #' -#' The default discrete colour scale. Defaults to [scale_fill_hue()]/[scale_fill_brewer()] -#' unless `type` (which defaults to the `ggplot2.discrete.fill`/`ggplot2.discrete.colour` options) -#' is specified. +#' The default discrete colour scale. #' #' @param palette One of the following: #' * `NULL` for the default palette stored in the theme. @@ -185,7 +175,9 @@ scale_fill_binned <- function(..., palette = NULL, aesthetics = "fill", guide = #' number of levels in the scale) returns the values that they should take. #' @param ... Additional parameters passed on to the scale type, #' @inheritParams discrete_scale -#' @param type One of the following: +#' @param type `r lifecycle::badge("superseded")` The preferred mechanism for +#' setting the default palette is by using the theme. For example: +#' `theme(palette.colour.discrete = "Okabe-Ito")`. One of the following: #' * A character vector of color codes. The codes are used for a 'manual' color #' scale as long as the number of codes exceeds the number of data levels #' (if there are more levels than codes, [scale_colour_hue()]/[scale_fill_hue()] diff --git a/man/scale_colour_continuous.Rd b/man/scale_colour_continuous.Rd index b7b482cb92..d9ab49b684 100644 --- a/man/scale_colour_continuous.Rd +++ b/man/scale_colour_continuous.Rd @@ -64,7 +64,7 @@ between 0 and 1 returns the corresponding output values. \item{na.value}{Missing values will be replaced with this value.} -\item{type}{One of the following: +\item{type}{\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#superseded}{\figure{lifecycle-superseded.svg}{options: alt='[Superseded]'}}}{\strong{[Superseded]}} One of the following: \itemize{ \item "gradient" (the default) \item "viridis" @@ -80,21 +80,13 @@ functions that assign discrete color bins to the continuous values instead of using a continuous color spectrum. } \details{ -All these colour scales use the \code{\link[=options]{options()}} mechanism to determine -default settings. Continuous colour scales default to the values of the -\code{ggplot2.continuous.colour} and \code{ggplot2.continuous.fill} options, and -binned colour scales default to the values of the \code{ggplot2.binned.colour} -and \code{ggplot2.binned.fill} options. These option values default to -\code{"gradient"}, which means that the scale functions actually used are -\code{\link[=scale_colour_gradient]{scale_colour_gradient()}}/\code{\link[=scale_fill_gradient]{scale_fill_gradient()}} for continuous scales and -\code{\link[=scale_colour_steps]{scale_colour_steps()}}/\code{\link[=scale_fill_steps]{scale_fill_steps()}} for binned scales. -Alternative option values are \code{"viridis"} or a different scale function. -See description of the \code{type} argument for details. - -Note that the binned colour scales will use the settings of -\code{ggplot2.continuous.colour} and \code{ggplot2.continuous.fill} as fallback, -respectively, if \code{ggplot2.binned.colour} or \code{ggplot2.binned.fill} are -not set. +\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#superseded}{\figure{lifecycle-superseded.svg}{options: alt='[Superseded]'}}}{\strong{[Superseded]}}: The mechanism of setting defaults via +\code{\link[=options]{options()}} is superseded by theme settings. The preferred method to change +the default palette of scales is via the theme, for example: +\code{theme(palette.colour.continuous = scales::pal_viridis())}. The +\code{ggplot2.continuous.colour} and \code{ggplot2.continuous.fill} options could be +used to set default continuous scales and \code{ggplot2.binned.colour} and +\code{ggplot2.binned.fill} options to set default binned scales. These scale functions are meant to provide simple defaults. If you want to manually set the colors of a scale, consider using diff --git a/man/scale_colour_discrete.Rd b/man/scale_colour_discrete.Rd index c86fd7b33c..87c8ad6f1c 100644 --- a/man/scale_colour_discrete.Rd +++ b/man/scale_colour_discrete.Rd @@ -40,7 +40,9 @@ number of levels in the scale) returns the values that they should take. missing values be displayed as? Does not apply to position scales where \code{NA} is always placed at the far right.} -\item{type}{One of the following: +\item{type}{\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#superseded}{\figure{lifecycle-superseded.svg}{options: alt='[Superseded]'}}}{\strong{[Superseded]}} The preferred mechanism for +setting the default palette is by using the theme. For example: +\code{theme(palette.colour.discrete = "Okabe-Ito")}. One of the following: \itemize{ \item A character vector of color codes. The codes are used for a 'manual' color scale as long as the number of codes exceeds the number of data levels @@ -56,9 +58,7 @@ want to change the color palette based on the number of levels. }} } \description{ -The default discrete colour scale. Defaults to \code{\link[=scale_fill_hue]{scale_fill_hue()}}/\code{\link[=scale_fill_brewer]{scale_fill_brewer()}} -unless \code{type} (which defaults to the \code{ggplot2.discrete.fill}/\code{ggplot2.discrete.colour} options) -is specified. +The default discrete colour scale. } \examples{ # A standard plot From 34b35edbe70b5258d7bf25979bb54001d140f621 Mon Sep 17 00:00:00 2001 From: Teun van den Brand Date: Wed, 7 May 2025 10:33:40 +0200 Subject: [PATCH 7/9] supersede `facet_wrap(as.table)` --- R/facet-wrap.R | 5 +++++ man/facet_wrap.Rd | 8 +++++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/R/facet-wrap.R b/R/facet-wrap.R index e1eda21cdb..2c8fcbc2de 100644 --- a/R/facet-wrap.R +++ b/R/facet-wrap.R @@ -45,6 +45,11 @@ NULL #' the exterior axes get labels, and the interior axes get none. When #' `"all_x"` or `"all_y"`, only draws the labels at the interior axes in the #' x- or y-direction respectively. +#' @param as.table `r lifecycle::badge("superseded")` The `as.table` argument +#' is now absorbed into the `dir` argument via the two letter options. +#' If `TRUE`, the facets are laid out like a table with highest values at the +#' bottom-right. If `FALSE`, the facets are laid out like a plot with the +#' highest value at the top-right. #' #' @section Layer layout: #' The [`layer(layout)`][layer()] argument in context of `facet_wrap()` can take diff --git a/man/facet_wrap.Rd b/man/facet_wrap.Rd index 4cfcf1284e..10302c35f4 100644 --- a/man/facet_wrap.Rd +++ b/man/facet_wrap.Rd @@ -58,9 +58,11 @@ functions for different kind of labels, for example use \code{\link[=label_parse formatting facet labels. \code{\link[=label_value]{label_value()}} is used by default, check it for more details and pointers to other options.} -\item{as.table}{If \code{TRUE}, the default, the facets are laid out like -a table with highest values at the bottom-right. If \code{FALSE}, the -facets are laid out like a plot with the highest value at the top-right.} +\item{as.table}{\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#superseded}{\figure{lifecycle-superseded.svg}{options: alt='[Superseded]'}}}{\strong{[Superseded]}} The \code{as.table} argument +is now absorbed into the \code{dir} argument via the two letter options. +If \code{TRUE}, the facets are laid out like a table with highest values at the +bottom-right. If \code{FALSE}, the facets are laid out like a plot with the +highest value at the top-right.} \item{switch}{By default, the labels are displayed on the top and right of the plot. If \code{"x"}, the top labels will be From 8e5d6e2c093fa8b0322a10b8ddce1c8a391bd037 Mon Sep 17 00:00:00 2001 From: Teun van den Brand Date: Wed, 7 May 2025 14:59:56 +0200 Subject: [PATCH 8/9] supersede `labs()` variants --- R/labels.R | 7 +++++++ man/labs.Rd | 4 ++++ 2 files changed, 11 insertions(+) diff --git a/R/labels.R b/R/labels.R index 27c1e96de6..2ccfda8521 100644 --- a/R/labels.R +++ b/R/labels.R @@ -200,19 +200,26 @@ labs <- function(..., title = waiver(), subtitle = waiver(), caption = waiver(), #' @rdname labs #' @export +#' @description +#' `r lifecycle::badge("superseded")`: `xlab()`, `ylab()` and `ggtitle()` are +#' superseded. It is recommended to use the `labs(x, y, title, subtitle)` +#' arguments instead. xlab <- function(label) { + lifecycle::signal_stage("superseded", "xlab()", "labs(x)") labs(x = label) } #' @rdname labs #' @export ylab <- function(label) { + lifecycle::signal_stage("superseded", "ylab()", "labs(y)") labs(y = label) } #' @rdname labs #' @export ggtitle <- function(label, subtitle = waiver()) { + lifecycle::signal_stage("superseded", "ggtitle()", "labs(title, subtitle)") labs(title = label, subtitle = subtitle) } diff --git a/man/labs.Rd b/man/labs.Rd index 18cd7690f6..3b97fa9c52 100644 --- a/man/labs.Rd +++ b/man/labs.Rd @@ -64,6 +64,10 @@ main findings. It's common to use the \code{caption} to provide information about the data source. \code{tag} can be used for adding identification tags to differentiate between multiple plots. +\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#superseded}{\figure{lifecycle-superseded.svg}{options: alt='[Superseded]'}}}{\strong{[Superseded]}}: \code{xlab()}, \code{ylab()} and \code{ggtitle()} are +superseded. It is recommended to use the \code{labs(x, y, title, subtitle)} +arguments instead. + \code{get_labs()} retrieves completed labels from a plot. } \details{ From 09ee69b7d8563c3f9f96193b47e31088775527ef Mon Sep 17 00:00:00 2001 From: Teun van den Brand Date: Wed, 7 May 2025 17:24:35 +0200 Subject: [PATCH 9/9] fix dumb mistake --- R/labels.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/labels.R b/R/labels.R index 2ccfda8521..7b113ee694 100644 --- a/R/labels.R +++ b/R/labels.R @@ -219,7 +219,7 @@ ylab <- function(label) { #' @rdname labs #' @export ggtitle <- function(label, subtitle = waiver()) { - lifecycle::signal_stage("superseded", "ggtitle()", "labs(title, subtitle)") + lifecycle::signal_stage("superseded", "ggtitle()", I("labs(title, subtitle)")) labs(title = label, subtitle = subtitle) }