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

Using label_colour to get edge colour for label colour #238

Closed
malthesr opened this issue Mar 21, 2020 · 0 comments
Closed

Using label_colour to get edge colour for label colour #238

malthesr opened this issue Mar 21, 2020 · 0 comments

Comments

@malthesr
Copy link

In the man page ?geom_edge_link, under Arguments, it says

label_colour The colour of the edge label. If NA it will use the colour of the edge.

I've been trying to make use of this to make the edge label inherit the colour of its edge, but I can't make it work. Leaving out the label_colour argument gives me black labels, while explicitly setting label_colour = NA removes the edge labels altogether.

MWE to illustrate (ggraph 2.0.2):

library(tidygraph)
#> 
#> Attaching package: 'tidygraph'
#> The following object is masked from 'package:stats':
#> 
#>     filter
library(ggraph)
#> Loading required package: ggplot2

g <- create_ring(10) %>% 
  activate("edges") %>%
  mutate(
    label = letters[1:10],
    colour = rep(c(TRUE, FALSE), 5)
  )

ggraph(g) + 
  geom_edge_link(
    aes(label = label, colour = colour)
  ) +
  geom_node_point()
#> Using `stress` as default layout

ggraph(g) + 
  geom_edge_link(
    aes(label = label, colour = colour),
    label_colour = NA # Makes the labels disappear
  ) +
  geom_node_point()
#> Using `stress` as default layout

Created on 2020-03-21 by the reprex package (v0.2.1)

Am I misunderstanding the docs here? I would've thought that either of these would've made the edge labels take the colours of their associated edge. As far as I can tell, the same thing happens label_alpha.

Thank you for a great package.

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

No branches or pull requests

1 participant