diff --git a/NEWS.md b/NEWS.md index c0f7809db6..d8167c66c9 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). * Axis labels are now preserved better when using `coord_sf(expand = TRUE)` and graticule lines are straight but do not meet the edge (@teunbrand, #2985). * Attempt to boost detail in `coord_polar()` and `coord_radial()` near the diff --git a/R/geom-boxplot.R b/R/geom-boxplot.R index edd6117538..96c6ed9d35 100644 --- a/R/geom-boxplot.R +++ b/R/geom-boxplot.R @@ -239,6 +239,15 @@ GeomBoxplot <- ggproto("GeomBoxplot", Geom, extra_params = c("na.rm", "orientation", "outliers"), setup_params = function(data, params) { + if ("fatten" %in% names(params)) { + 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 7316033de6..8f9d8ccd74 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-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/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) }, 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.}