Skip to content

Deprecate geom_errorbarh() #5961

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 11 commits into from
Nov 11, 2024
Merged
1 change: 0 additions & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
34 changes: 34 additions & 0 deletions R/geom-errorbar.R
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,34 @@ geom_errorbar <- function(mapping = NULL, data = NULL,
)
}

#' @export
#' @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",
...,
orientation = "y",
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,
stat = stat,
position = position,
...,
orientation = orientation,
na.rm = na.rm,
show.legend = show.legend,
inherit.aes = inherit.aes
)
}

#' @rdname ggplot2-ggproto
#' @format NULL
#' @usage NULL
Expand Down Expand Up @@ -74,3 +102,9 @@ GeomErrorbar <- ggproto("GeomErrorbar", Geom,

rename_size = TRUE
)

#' @rdname ggplot2-ggproto
#' @format NULL
#' @usage NULL
#' @export
GeomErrorbarh <- ggproto("GeomErrorbarh", GeomErrorbar)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Couldn't we throw in a deprecation warning in setup_param() and see how that works?

If we give it the same ID as the one in the constructor we can ensure it only fires once for those that uses the constructor

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah works great:

devtools::load_all("~/packages/ggplot2")
#> ℹ Loading ggplot2

df <- data.frame(
  trt = factor(c(1, 1, 2, 2)),
  resp = c(1, 5, 3, 4),
  group = factor(c(1, 2, 1, 2)),
  upper = c(1.1, 5.3, 3.3, 4.2),
  lower = c(0.8, 4.6, 2.4, 3.6)
)

ggplot(df, aes(resp, trt, colour = group)) +
  layer(
    geom = "errorbarh",
    stat = "identity",
    position = "identity",
    mapping = aes(xmin = lower, xmax = upper),
    params = list(width = 0.2, na.rm = FALSE, orientation = NA)
  )
#> Warning: `geom_errobarh()` was deprecated in ggplot2 3.5.2.
#> ℹ Please use the `orientation` argument of `geom_errorbar()` instead.
#> This warning is displayed once every 8 hours.
#> Call `lifecycle::last_lifecycle_warnings()` to see where this warning was
#> generated.

ggplot(df, aes(resp, trt, colour = group)) +
  geom_errorbarh(aes(xmin = lower, xmax = upper))

Created on 2024-09-13 with reprex v2.1.1

85 changes: 0 additions & 85 deletions R/geom-errorbarh.R

This file was deleted.

3 changes: 1 addition & 2 deletions R/geom-linerange.R
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
145 changes: 0 additions & 145 deletions man/geom_errorbarh.Rd

This file was deleted.

20 changes: 18 additions & 2 deletions man/geom_linerange.Rd

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

35 changes: 17 additions & 18 deletions man/ggplot2-ggproto.Rd

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

2 changes: 1 addition & 1 deletion tests/testthat/test-function-args.R
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading