Skip to content

Deprecate geom_errorbarh() - #5961

Merged
teunbrand merged 11 commits into
tidyverse:mainfrom
teunbrand:deprecate_errorbarh
Nov 11, 2024
Merged

teunbrand merged 11 commits into
tidyverse:mainfrom
teunbrand:deprecate_errorbarh

Conversation

@teunbrand

Copy link
Copy Markdown
Collaborator

This PR aims to fix #3506 (comment).

Briefly, geom_errorbarh() is now geom_errorbar(orientation = "y") + deprecation warning. The <GeomErrorbarh> ggproto class is kept as people have extended it (see e.g. here), but it is just a copy of <GeomErrorbar>. It also suffers from #3798 in that we don't really have a deprecation process for ggproto classes in place.

Comment thread R/geom-errorbar.R Outdated
#' @format NULL
#' @usage NULL
#' @export
GeomErrorbarh <- ggproto("GeomErrorbarh", GeomErrorbar)

Copy link
Copy Markdown
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
Copy Markdown
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

Merge branch 'main' into deprecate_errorbarh

# Conflicts:
#	R/geom-errorbarh.R
#	man/geom_errorbarh.Rd

@thomasp85 thomasp85 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM

@teunbrand
teunbrand merged commit 926f290 into tidyverse:main Nov 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants