Skip to content
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

Deprecate geom_errorbarh() #5961

Open
wants to merge 11 commits into
base: main
Choose a base branch
from

Conversation

teunbrand
Copy link
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.

#' @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

Merge branch 'main' into deprecate_errorbarh

# Conflicts:
#	R/geom-errorbarh.R
#	man/geom_errorbarh.Rd
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