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

Keep colors of unhighlighted #152

Closed
jzadra opened this issue Jun 28, 2020 · 3 comments · Fixed by #167
Closed

Keep colors of unhighlighted #152

jzadra opened this issue Jun 28, 2020 · 3 comments · Fixed by #167

Comments

@jzadra
Copy link

jzadra commented Jun 28, 2020

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)

@yutannihilation
Copy link
Owner

Thanks, I'll consider if gghighlight can support unhighlighted_params = list(colour = NULL) as an intent NOT to unhighlight colour aes...

@LeiGuo0812
Copy link

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.

@yutannihilation
Copy link
Owner

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants