Keep colors of unhighlighted
jzadra opened this issue · comments
Is there any way to keep all the colors of the unhighlighted data? I'd like to just reduce their alpha while keeping the colors. I've tried (given that the original aes for color was my_color_var
:
unhighlighted_params = list(alpha = .5, color = aes(my_color_var))
and
unhighlighted_params = list(alpha = .5, color = my_color_var)
Thanks, I'll consider if gghighlight can support unhighlighted_params = list(colour = NULL)
as an intent NOT to unhighlight colour
aes...
I strongly agree. It is a very useful function to keep the original colors of unhighlighted data, and this would make gghighlight
a more powerful tool.
Now this is possible. Thanks for your suggestion!
set.seed(2)
d <- purrr::map_dfr(
letters,
~ data.frame(
idx = 1:400,
value = cumsum(runif(400, -1, 1)),
type = .,
flag = sample(c(TRUE, FALSE), size = 400, replace = TRUE),
stringsAsFactors = FALSE
)
)
# Preserve the colour and modify alpha instead
ggplot(d) +
geom_line(aes(idx, value, colour = type)) +
gghighlight(max(value) > 19,
unhighlighted_params = list(colour = NULL, alpha = 0.3))
#> label_key: type