-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Allow select alpha to be applied on fill (default), colour, or both #3485
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
Conversation
I feel certain this is the wrong API. It's better (and easier to implement!) to set up a hierarchy of aesthetics. This is done e.g. in ggridges, where library(ggplot2)
library(ggridges)
# without `point_alpha`
ggplot(iris, aes(x=Sepal.Length, y=Species)) +
geom_density_ridges(
jittered_points = TRUE,
position = position_points_jitter(width = 0.05, height = 0),
point_shape = '|', point_size = 3, alpha = 0.4,
)
#> Picking joint bandwidth of 0.181 # with `point_alpha`
ggplot(iris, aes(x=Sepal.Length, y=Species)) +
geom_density_ridges(
jittered_points = TRUE,
position = position_points_jitter(width = 0.05, height = 0),
point_shape = '|', point_size = 3, point_alpha = 1, alpha = 0.4,
)
#> Picking joint bandwidth of 0.181 Created on 2019-08-15 by the reprex package (v0.3.0) Whether we want this in ggplot2 proper is a separate question though. I don't see a strong need. For all geoms provided by ggplot2 one can always achieve the same effect by using two separate geoms (e.g., Another relevant discussion: #1523 |
Sound like you are right.
For |
But, it's still possible. I agree it would be nice to have some option to make alpha affect on lines, but I don't see a good reason to do so, considering the difficulty of making changes on these fundamental geoms and maintaining them. As we saw on #1371, I think it's too late to change.... |
I see... |
You can create an extension package, though. |
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/ |
This PR is related to #1371
In the discussion in #1371, a change was attempted to apply alpha both on
colour
andfill
.In this PR, we can select alpha to be applied on
fill
(default),colour
, orboth
.The default selection is
fill
and thus is safe in terms of backward compatibility.Currently,
alpha_to
is implemented forgeom_polygon
,geom_rect
, andgeom_ribbon
.It works in some more (e.g.,
geom_density
), but not all (geom_bar
).So I need some more to work on.
Before I update other functions, I'd like to ask @hadley if you like my PR.
Examples
Varying
alpha_to
byfill
,colour
, andboth
Created on 2019-08-15 by the reprex package (v0.3.0)