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
Labels
bug an unexpected problem or unintended behavior scales 🐍

Comments

@smouksassi
Copy link

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

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 hadley added bug an unexpected problem or unintended behavior ready labels Jul 28, 2016
@hadley
Copy link
Member

hadley commented Sep 23, 2016

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

@clauswilke
Copy link
Member

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 wilkelab/ggplot2_archive that referenced this issue May 10, 2018
@hadley hadley closed this as completed in 8e365a4 May 10, 2018
@lock
Copy link

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.
Labels
bug an unexpected problem or unintended behavior scales 🐍
Projects
None yet
Development

No branches or pull requests

3 participants