You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
breaking change: alpha now impacts the line of stat_ based geoms. #1523
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.
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....
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:
Activity
antoine-lizee commentedon Jan 27, 2016
A solve-it-all solution would be to have two different
alphaparameters.joanwa commentedon Feb 2, 2016
yes, please either revert or two different alpha parameters. This change broke many of my graphs...
antoine-lizee commentedon Feb 6, 2016
Thanks!
yutannihilation commentedon 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
alphasemantics both for beginners and those who already got used to ggplot2....dhimmel commentedon Apr 20, 2016
+1 for separate parameters for
line_alphaandfill_alpha(or justalphaas it is currently).antoine-lizee commentedon Apr 20, 2016
To answer requests from @dhimmel and others who need lines representing densities with alpha,
geom_densityis the wrong tool as it is designed to show an area. To get a line, use directlystat_density(geom = "line", alpha = 0.1, ...). Example:dhimmel commentedon Apr 20, 2016
@antoine-lizee thanks for the workaround. I had to add
position='identity'inggplot2::stat_densityso the distributions were not stacked.