From 419fb2ebb80f794853fb7757d0411bef62a57019 Mon Sep 17 00:00:00 2001 From: Teun van den Brand Date: Thu, 12 Dec 2024 15:43:03 +0100 Subject: [PATCH 1/4] deprecate fatten --- R/geom-boxplot.R | 9 +++++++++ R/geom-crossbar.R | 11 ++++++++++- R/geom-pointrange.R | 8 +++++++- 3 files changed, 26 insertions(+), 2 deletions(-) diff --git a/R/geom-boxplot.R b/R/geom-boxplot.R index efb6dd14bd..7c60c42410 100644 --- a/R/geom-boxplot.R +++ b/R/geom-boxplot.R @@ -241,6 +241,15 @@ GeomBoxplot <- ggproto("GeomBoxplot", Geom, extra_params = c("na.rm", "width", "orientation", "outliers"), setup_params = function(data, params) { + if (lifecycle::is_present(params$fatten)) { + deprecate_soft0( + "3.6.0", "geom_boxplot(fatten)", + "geom_boxplot(median.linewidth)" + ) + } else { + # For backward compatibility reasons + params$fatten <- 2 + } params$flipped_aes <- has_flipped_aes(data, params) params }, diff --git a/R/geom-crossbar.R b/R/geom-crossbar.R index be7ce1f658..facd119d81 100644 --- a/R/geom-crossbar.R +++ b/R/geom-crossbar.R @@ -17,7 +17,7 @@ geom_crossbar <- function(mapping = NULL, data = NULL, box.color = NULL, box.linetype = NULL, box.linewidth = NULL, - fatten = 2.5, + fatten = deprecated(), na.rm = FALSE, orientation = NA, show.legend = NA, @@ -60,6 +60,15 @@ geom_crossbar <- function(mapping = NULL, data = NULL, #' @export GeomCrossbar <- ggproto("GeomCrossbar", Geom, setup_params = function(data, params) { + if (lifecycle::is_present(params$fatten)) { + deprecate_soft0( + "3.6.0", "geom_crossbar(fatten)", + "geom_crossbar(middle.linewidth)" + ) + } else { + # For backward compatibility reasons + params$fatten <- 2.5 + } GeomErrorbar$setup_params(data, params) }, diff --git a/R/geom-pointrange.R b/R/geom-pointrange.R index d0e5194311..1943bb4f4c 100644 --- a/R/geom-pointrange.R +++ b/R/geom-pointrange.R @@ -3,7 +3,7 @@ geom_pointrange <- function(mapping = NULL, data = NULL, stat = "identity", position = "identity", ..., - fatten = 4, + fatten = deprecated(), na.rm = FALSE, orientation = NA, show.legend = NA, @@ -42,6 +42,12 @@ GeomPointrange <- ggproto("GeomPointrange", Geom, required_aes = c("x", "y", "ymin|xmin", "ymax|xmax"), setup_params = function(data, params) { + if (lifecycle::is_present(params$fatten)) { + deprecate_soft0("3.6.0", "geom_pointrange(fatten)", I("the `size` aesthetic")) + } else { + # For backward compatibility reasons + params$fatten <- 4 + } GeomLinerange$setup_params(data, params) }, From c28b69f964cf37ad0b5466dbb7014b94f6b3854b Mon Sep 17 00:00:00 2001 From: Teun van den Brand Date: Thu, 12 Dec 2024 15:47:01 +0100 Subject: [PATCH 2/4] `fatten` isn't a formal argument to `geom_boxplot()` --- R/geom-boxplot.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/geom-boxplot.R b/R/geom-boxplot.R index 7c60c42410..b4d1e60467 100644 --- a/R/geom-boxplot.R +++ b/R/geom-boxplot.R @@ -241,7 +241,7 @@ GeomBoxplot <- ggproto("GeomBoxplot", Geom, extra_params = c("na.rm", "width", "orientation", "outliers"), setup_params = function(data, params) { - if (lifecycle::is_present(params$fatten)) { + if ("fatten" %in% names(params)) { deprecate_soft0( "3.6.0", "geom_boxplot(fatten)", "geom_boxplot(median.linewidth)" From aeadd548348befe36afec8a2db6ae9c8dea54eb0 Mon Sep 17 00:00:00 2001 From: Teun van den Brand Date: Thu, 12 Dec 2024 15:52:48 +0100 Subject: [PATCH 3/4] document --- R/geom-linerange.R | 6 +++--- man/geom_linerange.Rd | 10 +++++----- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/R/geom-linerange.R b/R/geom-linerange.R index 085d8f98a9..71c0799971 100644 --- a/R/geom-linerange.R +++ b/R/geom-linerange.R @@ -6,9 +6,9 @@ #' @eval rd_orientation() #' #' @eval rd_aesthetics("geom", "linerange", "Note that `geom_pointrange()` also understands `size` for the size of the points.") -#' @param fatten A multiplicative factor used to increase the size of the -#' middle bar in `geom_crossbar()` and the middle point in -#' `geom_pointrange()`. +#' @param fatten `r lifecycle::badge("deprecated")` A multiplicative factor +#' used to increase the size of the middle bar in `geom_crossbar()` and the +#' middle point in `geom_pointrange()`. #' @seealso #' [stat_summary()] for examples of these guys in use, #' [geom_smooth()] for continuous analogue diff --git a/man/geom_linerange.Rd b/man/geom_linerange.Rd index 93f340656e..0c77084236 100644 --- a/man/geom_linerange.Rd +++ b/man/geom_linerange.Rd @@ -23,7 +23,7 @@ geom_crossbar( box.color = NULL, box.linetype = NULL, box.linewidth = NULL, - fatten = 2.5, + fatten = deprecated(), na.rm = FALSE, orientation = NA, show.legend = NA, @@ -72,7 +72,7 @@ geom_pointrange( stat = "identity", position = "identity", ..., - fatten = 4, + fatten = deprecated(), na.rm = FALSE, orientation = NA, show.legend = NA, @@ -160,9 +160,9 @@ data's aesthetics.} \item{box.colour, box.color, box.linetype, box.linewidth}{Default aesthetics for the boxes. Set to \code{NULL} to inherit from the data's aesthetics.} -\item{fatten}{A multiplicative factor used to increase the size of the -middle bar in \code{geom_crossbar()} and the middle point in -\code{geom_pointrange()}.} +\item{fatten}{\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}} A multiplicative factor +used to increase the size of the middle bar in \code{geom_crossbar()} and the +middle point in \code{geom_pointrange()}.} \item{na.rm}{If \code{FALSE}, the default, missing values are removed with a warning. If \code{TRUE}, missing values are silently removed.} From b0f2cd3a5e5a1ff2aa1b5c807fde06068c475add Mon Sep 17 00:00:00 2001 From: Teun van den Brand Date: Thu, 12 Dec 2024 15:53:37 +0100 Subject: [PATCH 4/4] add news bullet --- NEWS.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/NEWS.md b/NEWS.md index dd574ac1aa..9c5d9b7b63 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,5 +1,7 @@ # ggplot2 (development version) +* The `fatten` argument has been deprecated in `geom_boxplot()`, + `geom_crossbar()` and `geom_pointrange()` (@teunbrand, #4881). * `guide_*()` can now accept two inside legend theme elements: `legend.position.inside` and `legend.justification.inside`, allowing inside legends to be placed at different positions. Only inside legends with the same