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

Fill aesthetic does not show in the legend guide for stat_summary #1546

Closed
smouksassi opened this issue Feb 16, 2016 · 5 comments
Closed

Fill aesthetic does not show in the legend guide for stat_summary #1546

smouksassi opened this issue Feb 16, 2016 · 5 comments

Comments

@smouksassi
Copy link

@smouksassi smouksassi commented Feb 16, 2016

require(ggplot2)

# using default summary function no fill in the legend 
ggplot(mtcars, aes(cyl ,mpg,col=factor(am),fill=factor(am))  )+
  geom_point()+
  stat_summary(aes(cyl,mpg), geom = "smooth")

# using median_hilow summary function no fill in the legend 
ggplot(mtcars, aes(cyl ,mpg,col=factor(am),fill=factor(am))  )+
  geom_point()+
  stat_summary(aes(cyl,mpg),fun.data = "median_hilow", geom = "smooth")

# geom smooth shows the fill in the legend which is the expected behavior
ggplot(mtcars, aes(cyl,mpg,col=factor(am),fill=factor(am))  )+
  geom_point()+
  geom_smooth()
@hadley
Copy link
Member

@hadley hadley commented Feb 17, 2016

Hmmmm, this is because the "smooth" key only displays the fill if the se parameter is true, and stat_summary() doesn't have an se parameter.

@smouksassi
Copy link
Author

@smouksassi smouksassi commented Feb 17, 2016

It used to work prior to 2.0. I see many us cases where stat_summary is used to visualize uncertainty or predictions interval around a fitted line and th fill works but down not show in legend.

@hadley
Copy link
Member

@hadley hadley commented Sep 23, 2016

@thomasp85 if you have time, could you please take a look at this too?

@clauswilke
Copy link
Member

@clauswilke clauswilke commented May 10, 2018

Slightly simpler reprex:

library(ggplot2)
ggplot(mtcars, aes(cyl, mpg, fill = factor(am))) +
  geom_smooth()
#> `geom_smooth()` using method = 'loess' and formula 'y ~ x'
#> There were 16 warnings (use warnings() to see them)

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

Created on 2018-05-10 by the reprex package (v0.2.0).

clauswilke added a commit to clauswilke/ggplot2 that referenced this issue May 10, 2018
@hadley hadley closed this in 8e365a4 May 10, 2018
@lock
Copy link

@lock lock bot commented Nov 6, 2018

This old issue has been automatically locked. If you believe you have found a related problem, please file a new issue (with reprex) and link to this issue. https://reprex.tidyverse.org/

@lock lock bot locked and limited conversation to collaborators Nov 6, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants