Skip to content

Using label_colour to get edge colour for label colour #238

Closed

Description

@malthesr

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.

Activity

  1. added a commit that references this issue on Jun 23, 2025
    1459103
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions