Skip to content

Conversation

teunbrand
Copy link
Collaborator

This PR aims to fix #5572 and amends #2567.

Briefly, instead of setting a default se = FALSE in GeomSmooth$draw_group(), we let the default se depend on the presence of ymin and ymax columns in GeomSmooth$setup_params(). This allows specifying a layer with geom = "smooth" to automatically infer the standard behaviour.

Of all examples in #2567, only the following has changed. Previously, no ribbons would be drawn because stat_summary() does not have an se parameter. Now, se = TRUE is inferred due to presence of ymin/ymax columns.

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

ggplot(mtcars, aes(cyl, mpg, fill = factor(am))) +
  stat_summary(geom = "smooth")
#> No summary function supplied, defaulting to `mean_se()`

Created on 2024-02-22 with reprex v2.1.0

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 e72d1a1 into tidyverse:main May 20, 2024
@teunbrand teunbrand deleted the smooth_se branch May 20, 2024 10:26
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.

layer does not work as expected for creating a geom_smooth plot

2 participants