Skip to content

Conversation

teunbrand
Copy link
Collaborator

This PR aims to fix #4881.

Briefly it deprecates fatten in geom_pointrange() (per linked issue), but also geom_boxplot() and geom_crossbar().
The parameter still works as it used to, but this at least starts the deprecation process.
There is a slight hiccup in geom_boxplot() as it isn't a named argument, but we check for if the argument has been picked up in the parameters.

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)
)

p <- ggplot(df, aes(x = trt, y = resp, col = group, ymin = lower, ymax = upper))

ggplotGrob(
  p + geom_pointrange() + 
    geom_crossbar() + 
    geom_boxplot()
) |> invisible()

ggplotGrob(
  p + geom_pointrange(fatten = 1) + 
    geom_crossbar(fatten = 1) + 
    geom_boxplot(fatten = 1)
) |> invisible()
#> Warning: The `fatten` argument of `geom_pointrange()` is deprecated as of ggplot2 3.6.0.
#> ℹ Please use the `size` aesthetic instead.
#> This warning is displayed once every 8 hours.
#> Call `lifecycle::last_lifecycle_warnings()` to see where this warning was
#> generated.
#> Warning: The `fatten` argument of `geom_crossbar()` is deprecated as of ggplot2 3.6.0.
#> ℹ Please use the `middle.linewidth` argument instead.
#> This warning is displayed once every 8 hours.
#> Call `lifecycle::last_lifecycle_warnings()` to see where this warning was
#> generated.
#> Warning: The `fatten` argument of `geom_boxplot()` is deprecated as of ggplot2 3.6.0.
#> ℹ Please use the `median.linewidth` argument instead.
#> This warning is displayed once every 8 hours.
#> Call `lifecycle::last_lifecycle_warnings()` to see where this warning was
#> generated.

Created on 2024-12-12 with reprex v2.1.1

Copy link
Member

@thomasp85 thomasp85 left a comment

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 f8d9825 into tidyverse:main Jan 28, 2025
13 checks passed
@teunbrand teunbrand deleted the deprecate_fatten branch January 28, 2025 11:05
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.

Can we deprecate fatten arg of geom_pointrange()?
2 participants