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

move make_summary_fun() to setup_params() #5971

Merged
merged 3 commits into from
Aug 26, 2024

Conversation

teunbrand
Copy link
Collaborator

This PR aims to fix #4647 (comment).

Briefly, stat_summary() and stat_summary_bin() use make_summary_fun() once per panel/group respectively, whereas it should be used once per layer. This PR moves the use of that function to the setup_params() method, so that we don't encounter the message multiple times, as per #4647 (comment).

An example:

library(ggplot2)

# Old messages
p <- ggplot(iris, aes(x = Sepal.Length, y = Sepal.Width, color = Species)) +
  stat_summary_bin(geom = "errorbar")
invisible(ggplot_build(p))
#> No summary function supplied, defaulting to `mean_se()`
#> No summary function supplied, defaulting to `mean_se()`
#> No summary function supplied, defaulting to `mean_se()`

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

# New message
p <- ggplot(iris, aes(x = Sepal.Length, y = Sepal.Width, color = Species)) +
  stat_summary_bin(geom = "errorbar")
invisible(ggplot_build(p))
#> No summary function supplied, defaulting to `mean_se()`

Created on 2024-07-03 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 78b3f3a into tidyverse:main Aug 26, 2024
13 checks passed
@teunbrand teunbrand deleted the reduce_summary_warnings branch August 26, 2024 12:07
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.

Width argument to geom_errorbar not passed on when using stat_summary_bin
2 participants