Skip to content

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

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

Closed
antoine-lizee opened this issue Jan 27, 2016 · 7 comments
Closed
Labels
bug an unexpected problem or unintended behavior
Milestone

Comments

@antoine-lizee
Copy link

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

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

@joanwa
Copy link

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 an unexpected problem or unintended behavior label Feb 4, 2016
@hadley hadley added this to the v2.1.0 milestone Feb 4, 2016
@hadley hadley closed this as completed in e3bd311 Feb 4, 2016
@antoine-lizee
Copy link
Author

Thanks!

@yutannihilation
Copy link
Member

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

No branches or pull requests

5 participants