From 7d247b06e45b5ea71b00d2c08e35ddfabd3fbc4e Mon Sep 17 00:00:00 2001 From: Teun van den Brand Date: Fri, 28 Jun 2024 10:10:14 +0200 Subject: [PATCH 01/10] copy `geom-errorbarh.R` contents into `geom-errorbar.R` file --- R/geom-errorbar.R | 85 ++++++++++++++++++++++++++++++++++++++++++++++ R/geom-errorbarh.R | 85 ---------------------------------------------- 2 files changed, 85 insertions(+), 85 deletions(-) delete mode 100644 R/geom-errorbarh.R diff --git a/R/geom-errorbar.R b/R/geom-errorbar.R index c02ab16ed9..71c7f07451 100644 --- a/R/geom-errorbar.R +++ b/R/geom-errorbar.R @@ -23,6 +23,53 @@ geom_errorbar <- function(mapping = NULL, data = NULL, ) } +#' Horizontal error bars +#' +#' A rotated version of [geom_errorbar()]. +#' +#' @eval rd_aesthetics("geom", "errorbarh") +#' @inheritParams layer +#' @inheritParams geom_point +#' @export +#' @examples +#' df <- data.frame( +#' trt = factor(c(1, 1, 2, 2)), +#' resp = c(1, 5, 3, 4), +#' group = factor(c(1, 2, 1, 2)), +#' se = c(0.1, 0.3, 0.3, 0.2) +#' ) +#' +#' # Define the top and bottom of the errorbars +#' +#' p <- ggplot(df, aes(resp, trt, colour = group)) +#' p + +#' geom_point() + +#' geom_errorbarh(aes(xmax = resp + se, xmin = resp - se)) +#' +#' p + +#' geom_point() + +#' geom_errorbarh(aes(xmax = resp + se, xmin = resp - se, height = .2)) +geom_errorbarh <- function(mapping = NULL, data = NULL, + stat = "identity", position = "identity", + ..., + na.rm = FALSE, + show.legend = NA, + inherit.aes = TRUE) { + layer( + data = data, + mapping = mapping, + stat = stat, + geom = GeomErrorbarh, + position = position, + show.legend = show.legend, + inherit.aes = inherit.aes, + params = list2( + na.rm = na.rm, + ... + ) + ) +} + #' @rdname ggplot2-ggproto #' @format NULL #' @usage NULL @@ -74,3 +121,41 @@ GeomErrorbar <- ggproto("GeomErrorbar", Geom, rename_size = TRUE ) + +#' @rdname ggplot2-ggproto +#' @format NULL +#' @usage NULL +#' @export +GeomErrorbarh <- ggproto("GeomErrorbarh", Geom, + default_aes = aes(colour = "black", linewidth = 0.5, linetype = 1, height = 0.5, + alpha = NA), + + draw_key = draw_key_path, + + required_aes = c("xmin", "xmax", "y"), + + setup_data = function(data, params) { + data$height <- data$height %||% + params$height %||% (resolution(data$y, FALSE, TRUE) * 0.9) + + transform(data, + ymin = y - height / 2, ymax = y + height / 2, height = NULL + ) + }, + + draw_panel = function(self, data, panel_params, coord, height = NULL, lineend = "butt") { + data <- check_linewidth(data, snake_class(self)) + GeomPath$draw_panel(data_frame0( + x = vec_interleave(data$xmax, data$xmax, NA, data$xmax, data$xmin, NA, data$xmin, data$xmin), + y = vec_interleave(data$ymin, data$ymax, NA, data$y, data$y, NA, data$ymin, data$ymax), + colour = rep(data$colour, each = 8), + alpha = rep(data$alpha, each = 8), + linewidth = rep(data$linewidth, each = 8), + linetype = rep(data$linetype, each = 8), + group = rep(1:(nrow(data)), each = 8), + .size = nrow(data) * 8 + ), panel_params, coord, lineend = lineend) + }, + + rename_size = TRUE +) diff --git a/R/geom-errorbarh.R b/R/geom-errorbarh.R deleted file mode 100644 index b23d125da4..0000000000 --- a/R/geom-errorbarh.R +++ /dev/null @@ -1,85 +0,0 @@ -#' Horizontal error bars -#' -#' A rotated version of [geom_errorbar()]. -#' -#' @eval rd_aesthetics("geom", "errorbarh") -#' @inheritParams layer -#' @inheritParams geom_point -#' @export -#' @examples -#' df <- data.frame( -#' trt = factor(c(1, 1, 2, 2)), -#' resp = c(1, 5, 3, 4), -#' group = factor(c(1, 2, 1, 2)), -#' se = c(0.1, 0.3, 0.3, 0.2) -#' ) -#' -#' # Define the top and bottom of the errorbars -#' -#' p <- ggplot(df, aes(resp, trt, colour = group)) -#' p + -#' geom_point() + -#' geom_errorbarh(aes(xmax = resp + se, xmin = resp - se)) -#' -#' p + -#' geom_point() + -#' geom_errorbarh(aes(xmax = resp + se, xmin = resp - se, height = .2)) -geom_errorbarh <- function(mapping = NULL, data = NULL, - stat = "identity", position = "identity", - ..., - na.rm = FALSE, - show.legend = NA, - inherit.aes = TRUE) { - layer( - data = data, - mapping = mapping, - stat = stat, - geom = GeomErrorbarh, - position = position, - show.legend = show.legend, - inherit.aes = inherit.aes, - params = list2( - na.rm = na.rm, - ... - ) - ) -} - - -#' @rdname ggplot2-ggproto -#' @format NULL -#' @usage NULL -#' @export -GeomErrorbarh <- ggproto("GeomErrorbarh", Geom, - default_aes = aes(colour = "black", linewidth = 0.5, linetype = 1, height = 0.5, - alpha = NA), - - draw_key = draw_key_path, - - required_aes = c("xmin", "xmax", "y"), - - setup_data = function(data, params) { - data$height <- data$height %||% - params$height %||% (resolution(data$y, FALSE, TRUE) * 0.9) - - transform(data, - ymin = y - height / 2, ymax = y + height / 2, height = NULL - ) - }, - - draw_panel = function(self, data, panel_params, coord, height = NULL, lineend = "butt") { - data <- check_linewidth(data, snake_class(self)) - GeomPath$draw_panel(data_frame0( - x = vec_interleave(data$xmax, data$xmax, NA, data$xmax, data$xmin, NA, data$xmin, data$xmin), - y = vec_interleave(data$ymin, data$ymax, NA, data$y, data$y, NA, data$ymin, data$ymax), - colour = rep(data$colour, each = 8), - alpha = rep(data$alpha, each = 8), - linewidth = rep(data$linewidth, each = 8), - linetype = rep(data$linetype, each = 8), - group = rep(1:(nrow(data)), each = 8), - .size = nrow(data) * 8 - ), panel_params, coord, lineend = lineend) - }, - - rename_size = TRUE -) From b99c53db2b82cb2c9cabb2c94561dbe10f7aff3e Mon Sep 17 00:00:00 2001 From: Teun van den Brand Date: Fri, 28 Jun 2024 10:11:57 +0200 Subject: [PATCH 02/10] rewire `geom_errorbarh()` via `geom_errorbar(orientation = "y")` --- R/geom-errorbar.R | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/R/geom-errorbar.R b/R/geom-errorbar.R index 71c7f07451..0887ca3819 100644 --- a/R/geom-errorbar.R +++ b/R/geom-errorbar.R @@ -52,21 +52,20 @@ geom_errorbar <- function(mapping = NULL, data = NULL, geom_errorbarh <- function(mapping = NULL, data = NULL, stat = "identity", position = "identity", ..., + orientation = "y", na.rm = FALSE, show.legend = NA, inherit.aes = TRUE) { - layer( - data = data, + geom_errorbar( mapping = mapping, + data = data, stat = stat, - geom = GeomErrorbarh, position = position, - show.legend = show.legend, - inherit.aes = inherit.aes, - params = list2( - na.rm = na.rm, - ... - ) + ..., + orientation = orientation, + na.rm = na.rm, + show.legend = NA, + inherit.aes = TRUE ) } From cf02d04200580191bbf27607f89542ee21d728c0 Mon Sep 17 00:00:00 2001 From: Teun van den Brand Date: Fri, 28 Jun 2024 10:12:46 +0200 Subject: [PATCH 03/10] is copy of --- R/geom-errorbar.R | 34 +--------------------------------- 1 file changed, 1 insertion(+), 33 deletions(-) diff --git a/R/geom-errorbar.R b/R/geom-errorbar.R index 0887ca3819..a5673b7d5b 100644 --- a/R/geom-errorbar.R +++ b/R/geom-errorbar.R @@ -125,36 +125,4 @@ GeomErrorbar <- ggproto("GeomErrorbar", Geom, #' @format NULL #' @usage NULL #' @export -GeomErrorbarh <- ggproto("GeomErrorbarh", Geom, - default_aes = aes(colour = "black", linewidth = 0.5, linetype = 1, height = 0.5, - alpha = NA), - - draw_key = draw_key_path, - - required_aes = c("xmin", "xmax", "y"), - - setup_data = function(data, params) { - data$height <- data$height %||% - params$height %||% (resolution(data$y, FALSE, TRUE) * 0.9) - - transform(data, - ymin = y - height / 2, ymax = y + height / 2, height = NULL - ) - }, - - draw_panel = function(self, data, panel_params, coord, height = NULL, lineend = "butt") { - data <- check_linewidth(data, snake_class(self)) - GeomPath$draw_panel(data_frame0( - x = vec_interleave(data$xmax, data$xmax, NA, data$xmax, data$xmin, NA, data$xmin, data$xmin), - y = vec_interleave(data$ymin, data$ymax, NA, data$y, data$y, NA, data$ymin, data$ymax), - colour = rep(data$colour, each = 8), - alpha = rep(data$alpha, each = 8), - linewidth = rep(data$linewidth, each = 8), - linetype = rep(data$linetype, each = 8), - group = rep(1:(nrow(data)), each = 8), - .size = nrow(data) * 8 - ), panel_params, coord, lineend = lineend) - }, - - rename_size = TRUE -) +GeomErrorbarh <- ggproto("GeomErrorbarh", GeomErrorbar) From 4720a5deed1520cb45977dec1b21b2339411dbb5 Mon Sep 17 00:00:00 2001 From: Teun van den Brand Date: Fri, 28 Jun 2024 10:21:37 +0200 Subject: [PATCH 04/10] document `geom_errorbarh()` as deprecated along with rest of interval geoms --- R/geom-errorbar.R | 29 ++++------------------------- R/geom-linerange.R | 3 +-- 2 files changed, 5 insertions(+), 27 deletions(-) diff --git a/R/geom-errorbar.R b/R/geom-errorbar.R index a5673b7d5b..547d2568a1 100644 --- a/R/geom-errorbar.R +++ b/R/geom-errorbar.R @@ -23,32 +23,11 @@ geom_errorbar <- function(mapping = NULL, data = NULL, ) } -#' Horizontal error bars -#' -#' A rotated version of [geom_errorbar()]. -#' -#' @eval rd_aesthetics("geom", "errorbarh") -#' @inheritParams layer -#' @inheritParams geom_point #' @export -#' @examples -#' df <- data.frame( -#' trt = factor(c(1, 1, 2, 2)), -#' resp = c(1, 5, 3, 4), -#' group = factor(c(1, 2, 1, 2)), -#' se = c(0.1, 0.3, 0.3, 0.2) -#' ) -#' -#' # Define the top and bottom of the errorbars -#' -#' p <- ggplot(df, aes(resp, trt, colour = group)) -#' p + -#' geom_point() + -#' geom_errorbarh(aes(xmax = resp + se, xmin = resp - se)) -#' -#' p + -#' geom_point() + -#' geom_errorbarh(aes(xmax = resp + se, xmin = resp - se, height = .2)) +#' @rdname geom_linerange +#' @note +#' `geom_errorbarh()` is `r lifecycle::badge("deprecated")`. Use +#' `geom_errorbar(orientation = "y")` instead. geom_errorbarh <- function(mapping = NULL, data = NULL, stat = "identity", position = "identity", ..., diff --git a/R/geom-linerange.R b/R/geom-linerange.R index 7144d0084a..3e48884915 100644 --- a/R/geom-linerange.R +++ b/R/geom-linerange.R @@ -11,8 +11,7 @@ #' `geom_pointrange()`. #' @seealso #' [stat_summary()] for examples of these guys in use, -#' [geom_smooth()] for continuous analogue, -#' [geom_errorbarh()] for a horizontal error bar. +#' [geom_smooth()] for continuous analogue #' @export #' @inheritParams layer #' @inheritParams geom_bar From 157b47632aa545e163f9cf35eeabe10a0c1dd216 Mon Sep 17 00:00:00 2001 From: Teun van den Brand Date: Fri, 28 Jun 2024 10:24:40 +0200 Subject: [PATCH 05/10] throw deprecation warnings --- R/geom-errorbar.R | 3 +++ 1 file changed, 3 insertions(+) diff --git a/R/geom-errorbar.R b/R/geom-errorbar.R index 547d2568a1..d1f5242f96 100644 --- a/R/geom-errorbar.R +++ b/R/geom-errorbar.R @@ -35,6 +35,9 @@ geom_errorbarh <- function(mapping = NULL, data = NULL, na.rm = FALSE, show.legend = NA, inherit.aes = TRUE) { + deprecate_soft0( + "3.5.2", "geom_errobarh()", "geom_errorbar(orientation = \"y\")" + ) geom_errorbar( mapping = mapping, data = data, From a449a2549a8d339965952734656c92ddf175048f Mon Sep 17 00:00:00 2001 From: Teun van den Brand Date: Fri, 28 Jun 2024 10:24:57 +0200 Subject: [PATCH 06/10] excuse `geom_errorbarh()` from test --- tests/testthat/test-function-args.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/testthat/test-function-args.R b/tests/testthat/test-function-args.R index 2a78bf9f50..8308f706c0 100644 --- a/tests/testthat/test-function-args.R +++ b/tests/testthat/test-function-args.R @@ -13,7 +13,7 @@ test_that("geom_xxx and GeomXxx$draw arg defaults match", { geom_fun_names, c("geom_map", "geom_sf", "geom_smooth", "geom_column", "geom_area", "geom_density", "annotation_custom", "annotation_map", "annotation_raster", - "annotation_id") + "annotation_id", "geom_errobarh") ) # For each geom_xxx function and the corresponding GeomXxx$draw and From f50fdbeae8c7151c0677c77c17eb039d8d6782df Mon Sep 17 00:00:00 2001 From: Teun van den Brand Date: Fri, 28 Jun 2024 10:34:01 +0200 Subject: [PATCH 07/10] document --- DESCRIPTION | 1 - man/geom_errorbarh.Rd | 145 ----------------------------------------- man/geom_linerange.Rd | 20 +++++- man/ggplot2-ggproto.Rd | 35 +++++----- 4 files changed, 35 insertions(+), 166 deletions(-) delete mode 100644 man/geom_errorbarh.Rd diff --git a/DESCRIPTION b/DESCRIPTION index dcaf992c7f..11330c3309 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -151,7 +151,6 @@ Collate: 'geom-density2d.R' 'geom-dotplot.R' 'geom-errorbar.R' - 'geom-errorbarh.R' 'geom-freqpoly.R' 'geom-function.R' 'geom-hex.R' diff --git a/man/geom_errorbarh.Rd b/man/geom_errorbarh.Rd deleted file mode 100644 index f72ccd5a2a..0000000000 --- a/man/geom_errorbarh.Rd +++ /dev/null @@ -1,145 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/geom-errorbarh.R -\name{geom_errorbarh} -\alias{geom_errorbarh} -\title{Horizontal error bars} -\usage{ -geom_errorbarh( - mapping = NULL, - data = NULL, - stat = "identity", - position = "identity", - ..., - na.rm = FALSE, - show.legend = NA, - inherit.aes = TRUE -) -} -\arguments{ -\item{mapping}{Set of aesthetic mappings created by \code{\link[=aes]{aes()}}. If specified and -\code{inherit.aes = TRUE} (the default), it is combined with the default mapping -at the top level of the plot. You must supply \code{mapping} if there is no plot -mapping.} - -\item{data}{The data to be displayed in this layer. There are three -options: - -If \code{NULL}, the default, the data is inherited from the plot -data as specified in the call to \code{\link[=ggplot]{ggplot()}}. - -A \code{data.frame}, or other object, will override the plot -data. All objects will be fortified to produce a data frame. See -\code{\link[=fortify]{fortify()}} for which variables will be created. - -A \code{function} will be called with a single argument, -the plot data. The return value must be a \code{data.frame}, and -will be used as the layer data. A \code{function} can be created -from a \code{formula} (e.g. \code{~ head(.x, 10)}).} - -\item{stat}{The statistical transformation to use on the data for this layer. -When using a \verb{geom_*()} function to construct a layer, the \code{stat} -argument can be used the override the default coupling between geoms and -stats. The \code{stat} argument accepts the following: -\itemize{ -\item A \code{Stat} ggproto subclass, for example \code{StatCount}. -\item A string naming the stat. To give the stat as a string, strip the -function name of the \code{stat_} prefix. For example, to use \code{stat_count()}, -give the stat as \code{"count"}. -\item For more information and other ways to specify the stat, see the -\link[=layer_stats]{layer stat} documentation. -}} - -\item{position}{A position adjustment to use on the data for this layer. This -can be used in various ways, including to prevent overplotting and -improving the display. The \code{position} argument accepts the following: -\itemize{ -\item The result of calling a position function, such as \code{position_jitter()}. -This method allows for passing extra arguments to the position. -\item A string naming the position adjustment. To give the position as a -string, strip the function name of the \code{position_} prefix. For example, -to use \code{position_jitter()}, give the position as \code{"jitter"}. -\item For more information and other ways to specify the position, see the -\link[=layer_positions]{layer position} documentation. -}} - -\item{...}{Other arguments passed on to \code{\link[=layer]{layer()}}'s \code{params} argument. These -arguments broadly fall into one of 4 categories below. Notably, further -arguments to the \code{position} argument, or aesthetics that are required -can \emph{not} be passed through \code{...}. Unknown arguments that are not part -of the 4 categories below are ignored. -\itemize{ -\item Static aesthetics that are not mapped to a scale, but are at a fixed -value and apply to the layer as a whole. For example, \code{colour = "red"} -or \code{linewidth = 3}. The geom's documentation has an \strong{Aesthetics} -section that lists the available options. The 'required' aesthetics -cannot be passed on to the \code{params}. Please note that while passing -unmapped aesthetics as vectors is technically possible, the order and -required length is not guaranteed to be parallel to the input data. -\item When constructing a layer using -a \verb{stat_*()} function, the \code{...} argument can be used to pass on -parameters to the \code{geom} part of the layer. An example of this is -\code{stat_density(geom = "area", outline.type = "both")}. The geom's -documentation lists which parameters it can accept. -\item Inversely, when constructing a layer using a -\verb{geom_*()} function, the \code{...} argument can be used to pass on parameters -to the \code{stat} part of the layer. An example of this is -\code{geom_area(stat = "density", adjust = 0.5)}. The stat's documentation -lists which parameters it can accept. -\item The \code{key_glyph} argument of \code{\link[=layer]{layer()}} may also be passed on through -\code{...}. This can be one of the functions described as -\link[=draw_key]{key glyphs}, to change the display of the layer in the legend. -}} - -\item{na.rm}{If \code{FALSE}, the default, missing values are removed with -a warning. If \code{TRUE}, missing values are silently removed.} - -\item{show.legend}{logical. Should this layer be included in the legends? -\code{NA}, the default, includes if any aesthetics are mapped. -\code{FALSE} never includes, and \code{TRUE} always includes. -It can also be a named logical vector to finely select the aesthetics to -display.} - -\item{inherit.aes}{If \code{FALSE}, overrides the default aesthetics, -rather than combining with them. This is most useful for helper functions -that define both data and aesthetics and shouldn't inherit behaviour from -the default plot specification, e.g. \code{\link[=borders]{borders()}}.} -} -\description{ -A rotated version of \code{\link[=geom_errorbar]{geom_errorbar()}}. -} -\section{Aesthetics}{ - -\code{geom_errorbarh()} understands the following aesthetics (required aesthetics are in bold): -\itemize{ -\item \strong{\code{\link[=aes_position]{xmin}}} -\item \strong{\code{\link[=aes_position]{xmax}}} -\item \strong{\code{\link[=aes_position]{y}}} -\item \code{\link[=aes_colour_fill_alpha]{alpha}} -\item \code{\link[=aes_colour_fill_alpha]{colour}} -\item \code{\link[=aes_group_order]{group}} -\item \code{height} -\item \code{\link[=aes_linetype_size_shape]{linetype}} -\item \code{\link[=aes_linetype_size_shape]{linewidth}} -} -Learn more about setting these aesthetics in \code{vignette("ggplot2-specs")}. -} - -\examples{ -df <- data.frame( - trt = factor(c(1, 1, 2, 2)), - resp = c(1, 5, 3, 4), - group = factor(c(1, 2, 1, 2)), - se = c(0.1, 0.3, 0.3, 0.2) -) - -# Define the top and bottom of the errorbars - -p <- ggplot(df, aes(resp, trt, colour = group)) -p + - geom_point() + - geom_errorbarh(aes(xmax = resp + se, xmin = resp - se)) - -p + - geom_point() + - geom_errorbarh(aes(xmax = resp + se, xmin = resp - se, height = .2)) -} diff --git a/man/geom_linerange.Rd b/man/geom_linerange.Rd index 03eb82f896..8a037a85eb 100644 --- a/man/geom_linerange.Rd +++ b/man/geom_linerange.Rd @@ -4,6 +4,7 @@ \name{geom_crossbar} \alias{geom_crossbar} \alias{geom_errorbar} +\alias{geom_errorbarh} \alias{geom_linerange} \alias{geom_pointrange} \title{Vertical intervals: lines, crossbars & errorbars} @@ -33,6 +34,18 @@ geom_errorbar( inherit.aes = TRUE ) +geom_errorbarh( + mapping = NULL, + data = NULL, + stat = "identity", + position = "identity", + ..., + orientation = "y", + na.rm = FALSE, + show.legend = NA, + inherit.aes = TRUE +) + geom_linerange( mapping = NULL, data = NULL, @@ -160,6 +173,10 @@ the default plot specification, e.g. \code{\link[=borders]{borders()}}.} Various ways of representing a vertical interval defined by \code{x}, \code{ymin} and \code{ymax}. Each case draws a single graphical object. } +\note{ +\code{geom_errorbarh()} is \ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}}. Use +\code{geom_errorbar(orientation = "y")} instead. +} \section{Orientation}{ This geom treats each axis differently and, thus, can thus have two orientations. Often the orientation is easy to deduce from a combination of the given mappings and the types of positional scales in use. Thus, ggplot2 will by default try to guess which orientation the layer should have. Under rare circumstances, the orientation is ambiguous and guessing may fail. In that case the orientation can be specified directly using the \code{orientation} parameter, which can be either \code{"x"} or \code{"y"}. The value gives the axis that the geom should run along, \code{"x"} being the default orientation you would expect for the geom. @@ -233,6 +250,5 @@ geom_errorbar( } \seealso{ \code{\link[=stat_summary]{stat_summary()}} for examples of these guys in use, -\code{\link[=geom_smooth]{geom_smooth()}} for continuous analogue, -\code{\link[=geom_errorbarh]{geom_errorbarh()}} for a horizontal error bar. +\code{\link[=geom_smooth]{geom_smooth()}} for continuous analogue } diff --git a/man/ggplot2-ggproto.Rd b/man/ggplot2-ggproto.Rd index c3384f1e45..963df0278c 100644 --- a/man/ggplot2-ggproto.Rd +++ b/man/ggplot2-ggproto.Rd @@ -9,24 +9,23 @@ % R/geom-boxplot.R, R/geom-col.R, R/geom-path.R, R/geom-contour.R, % R/geom-crossbar.R, R/geom-segment.R, R/geom-curve.R, R/geom-ribbon.R, % R/geom-density.R, R/geom-density2d.R, R/geom-dotplot.R, R/geom-errorbar.R, -% R/geom-errorbarh.R, R/geom-function.R, R/geom-hex.R, R/geom-hline.R, -% R/geom-label.R, R/geom-linerange.R, R/geom-point.R, R/geom-pointrange.R, -% R/geom-quantile.R, R/geom-rug.R, R/geom-smooth.R, R/geom-spoke.R, -% R/geom-text.R, R/geom-tile.R, R/geom-violin.R, R/geom-vline.R, -% R/guide-.R, R/guide-axis.R, R/guide-axis-logticks.R, R/guide-axis-stack.R, -% R/guide-axis-theta.R, R/guide-legend.R, R/guide-bins.R, R/guide-colorbar.R, -% R/guide-colorsteps.R, R/guide-custom.R, R/guide-none.R, R/guide-old.R, -% R/layout.R, R/position-.R, R/position-dodge.R, R/position-dodge2.R, -% R/position-identity.R, R/position-jitter.R, R/position-jitterdodge.R, -% R/position-nudge.R, R/position-stack.R, R/scale-.R, R/scale-binned.R, -% R/scale-continuous.R, R/scale-date.R, R/scale-discrete-.R, -% R/scale-identity.R, R/stat-align.R, R/stat-bin.R, R/stat-bin2d.R, -% R/stat-bindot.R, R/stat-binhex.R, R/stat-boxplot.R, R/stat-contour.R, -% R/stat-count.R, R/stat-density-2d.R, R/stat-density.R, R/stat-ecdf.R, -% R/stat-ellipse.R, R/stat-function.R, R/stat-identity.R, R/stat-qq-line.R, -% R/stat-qq.R, R/stat-quantilemethods.R, R/stat-smooth.R, R/stat-sum.R, -% R/stat-summary-2d.R, R/stat-summary-bin.R, R/stat-summary-hex.R, -% R/stat-summary.R, R/stat-unique.R, R/stat-ydensity.R +% R/geom-function.R, R/geom-hex.R, R/geom-hline.R, R/geom-label.R, +% R/geom-linerange.R, R/geom-point.R, R/geom-pointrange.R, R/geom-quantile.R, +% R/geom-rug.R, R/geom-smooth.R, R/geom-spoke.R, R/geom-text.R, +% R/geom-tile.R, R/geom-violin.R, R/geom-vline.R, R/guide-.R, R/guide-axis.R, +% R/guide-axis-logticks.R, R/guide-axis-stack.R, R/guide-axis-theta.R, +% R/guide-legend.R, R/guide-bins.R, R/guide-colorbar.R, R/guide-colorsteps.R, +% R/guide-custom.R, R/guide-none.R, R/guide-old.R, R/layout.R, R/position-.R, +% R/position-dodge.R, R/position-dodge2.R, R/position-identity.R, +% R/position-jitter.R, R/position-jitterdodge.R, R/position-nudge.R, +% R/position-stack.R, R/scale-.R, R/scale-binned.R, R/scale-continuous.R, +% R/scale-date.R, R/scale-discrete-.R, R/scale-identity.R, R/stat-align.R, +% R/stat-bin.R, R/stat-bin2d.R, R/stat-bindot.R, R/stat-binhex.R, +% R/stat-boxplot.R, R/stat-contour.R, R/stat-count.R, R/stat-density-2d.R, +% R/stat-density.R, R/stat-ecdf.R, R/stat-ellipse.R, R/stat-function.R, +% R/stat-identity.R, R/stat-qq-line.R, R/stat-qq.R, R/stat-quantilemethods.R, +% R/stat-smooth.R, R/stat-sum.R, R/stat-summary-2d.R, R/stat-summary-bin.R, +% R/stat-summary-hex.R, R/stat-summary.R, R/stat-unique.R, R/stat-ydensity.R \docType{data} \name{ggplot2-ggproto} \alias{ggplot2-ggproto} From 1bdc819e46f108214b9d4db4a847e72f979ed28c Mon Sep 17 00:00:00 2001 From: Teun van den Brand Date: Fri, 28 Jun 2024 10:42:00 +0200 Subject: [PATCH 08/10] fix mistakes in passing args --- R/geom-errorbar.R | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/R/geom-errorbar.R b/R/geom-errorbar.R index d1f5242f96..04f9b72854 100644 --- a/R/geom-errorbar.R +++ b/R/geom-errorbar.R @@ -46,8 +46,8 @@ geom_errorbarh <- function(mapping = NULL, data = NULL, ..., orientation = orientation, na.rm = na.rm, - show.legend = NA, - inherit.aes = TRUE + show.legend = show.legend, + inherit.aes = inherit.aes ) } From 1bd22b74d5f17749d00c5edff51bed306f46a08b Mon Sep 17 00:00:00 2001 From: Teun van den Brand Date: Fri, 13 Sep 2024 10:37:48 +0200 Subject: [PATCH 09/10] Let `GeomErrorbarh` throw deprecation message with same `id` --- R/geom-errorbar.R | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/R/geom-errorbar.R b/R/geom-errorbar.R index 04f9b72854..ad8ac99655 100644 --- a/R/geom-errorbar.R +++ b/R/geom-errorbar.R @@ -36,7 +36,8 @@ geom_errorbarh <- function(mapping = NULL, data = NULL, show.legend = NA, inherit.aes = TRUE) { deprecate_soft0( - "3.5.2", "geom_errobarh()", "geom_errorbar(orientation = \"y\")" + "3.5.2", "geom_errobarh()", "geom_errorbar(orientation = \"y\")", + id = "no-more-errorbarh" ) geom_errorbar( mapping = mapping, @@ -107,4 +108,13 @@ GeomErrorbar <- ggproto("GeomErrorbar", Geom, #' @format NULL #' @usage NULL #' @export -GeomErrorbarh <- ggproto("GeomErrorbarh", GeomErrorbar) +GeomErrorbarh <- ggproto( + "GeomErrorbarh", GeomErrorbar, + setup_params = function(data, params) { + deprecate_soft0( + "3.5.2", "geom_errobarh()", "geom_errorbar(orientation = \"y\")", + id = "no-more-errorbarh" + ) + GeomLinerange$setup_params(data, params) + } +) From cd17e69d04e99776f5f2f74c1ffa6d8977038820 Mon Sep 17 00:00:00 2001 From: Teun van den Brand Date: Fri, 13 Sep 2024 10:44:54 +0200 Subject: [PATCH 10/10] test for deprecation messages --- tests/testthat/test-function-args.R | 2 +- tests/testthat/test-geom-errorbar.R | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 tests/testthat/test-geom-errorbar.R diff --git a/tests/testthat/test-function-args.R b/tests/testthat/test-function-args.R index 8308f706c0..f7be015fa7 100644 --- a/tests/testthat/test-function-args.R +++ b/tests/testthat/test-function-args.R @@ -13,7 +13,7 @@ test_that("geom_xxx and GeomXxx$draw arg defaults match", { geom_fun_names, c("geom_map", "geom_sf", "geom_smooth", "geom_column", "geom_area", "geom_density", "annotation_custom", "annotation_map", "annotation_raster", - "annotation_id", "geom_errobarh") + "annotation_id", "geom_errorbarh") ) # For each geom_xxx function and the corresponding GeomXxx$draw and diff --git a/tests/testthat/test-geom-errorbar.R b/tests/testthat/test-geom-errorbar.R new file mode 100644 index 0000000000..bdfdf3f88d --- /dev/null +++ b/tests/testthat/test-geom-errorbar.R @@ -0,0 +1,16 @@ +test_that("geom_errorbarh throws deprecation messages", { + + lifecycle::expect_deprecated(geom_errorbarh()) + + p <- ggplot( + data.frame(y = "A", min = 0, max = 10), + aes(y = y, xmin = min, xmax = max) + ) + + layer( + geom = "errorbarh", + stat = "identity", + position = "identity" + ) + + lifecycle::expect_deprecated(ggplot_build(p)) +})