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

breaking change: alpha now impacts the line of stat_ based geoms. #1523

Closed
antoine-lizee opened this issue Jan 27, 2016 · 7 comments
Closed

breaking change: alpha now impacts the line of stat_ based geoms. #1523

antoine-lizee opened this issue Jan 27, 2016 · 7 comments
Labels
bug
Milestone

Comments

@antoine-lizee
Copy link

@antoine-lizee antoine-lizee commented Jan 27, 2016

This has changed following #1371, and I think (personally) that this is the wrong decision.
Pros: it's slightly more 'natural' to have alpha impacting both the line and fill (?)
Cons: the line texture is modified by the alpha parameter in a way that is irreversible, and thus you need a different geom for the common use case (to me) of having a solid line with a transparent filling.
Here is an example:

ggplot(diamonds %>% filter(cut %in% c("Very Good", "Ideal")), aes(x = price, fill = cut)) + theme_bw() + 
  geom_histogram(binwidth = 1000) +
  geom_density(aes(x = price, y = ..count.. * 1000), color = "NA", alpha = 0.3) +
  geom_density(aes(x = price, y = ..count.. * 1000), color = "black", fill = NA) +
  facet_grid(cut ~ ., scales = "free_y", space = "free_y")

I would vote for reverting this behavior, as I'm pretty sure it's breaking more graphing code now than it would if reverted for 2.1.

The downside of the old behavior is that you need to change the color directly if you want something lighter.

@antoine-lizee
Copy link
Author

@antoine-lizee antoine-lizee commented Jan 27, 2016

A solve-it-all solution would be to have two different alpha parameters.

@joanwa
Copy link

@joanwa joanwa commented Feb 2, 2016

yes, please either revert or two different alpha parameters. This change broke many of my graphs...

@hadley hadley added the bug label Feb 4, 2016
@hadley hadley added this to the v2.1.0 milestone Feb 4, 2016
@hadley hadley closed this in e3bd311 Feb 4, 2016
@antoine-lizee
Copy link
Author

@antoine-lizee antoine-lizee commented Feb 6, 2016

Thanks!

@yutannihilation
Copy link
Member

@yutannihilation yutannihilation commented Feb 6, 2016

I'm sorry for those who suffered with the change I proposed 😭
Hope someday some great person will discover some great solution which has more easier alpha semantics both for beginners and those who already got used to ggplot2....

@dhimmel
Copy link

@dhimmel dhimmel commented Apr 20, 2016

+1 for separate parameters for line_alpha and fill_alpha (or just alpha as it is currently).

@antoine-lizee
Copy link
Author

@antoine-lizee antoine-lizee commented Apr 20, 2016

To answer requests from @dhimmel and others who need lines representing densities with alpha, geom_density is the wrong tool as it is designed to show an area. To get a line, use directly stat_density(geom = "line", alpha = 0.1, ...). Example:

ggplot(diamonds %>% filter(cut %in% c("Very Good", "Ideal")), aes(x = price, fill = cut)) + theme_bw() + 
  geom_histogram(binwidth = 1000) +
  stat_density(aes(x = price, y = ..count.. * 1000), geom = "line", color = "black", alpha = 0.3) +
  facet_grid(cut ~ ., scales = "free_y", space = "free_y")
@dhimmel
Copy link

@dhimmel dhimmel commented Apr 20, 2016

@antoine-lizee thanks for the workaround. I had to add position='identity' in ggplot2::stat_density so the distributions were not stacked.

@lock lock bot locked as resolved and limited conversation to collaborators Jun 19, 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
5 participants