Skip to content

move make_summary_fun() to setup_params() - #5971

Merged
teunbrand merged 3 commits into
tidyverse:mainfrom
teunbrand:reduce_summary_warnings
Aug 26, 2024
Merged

teunbrand merged 3 commits into
tidyverse:mainfrom
teunbrand:reduce_summary_warnings

Conversation

@teunbrand

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

@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 78b3f3a into tidyverse:main Aug 26, 2024
@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