Skip to content

label_parse for edges? #245

Closed
Closed

Description

@tarball11

I've been trying to build a pretty simple graph that uses styled text (a simple equation) on the edge labels, but the label_parse argument to geom_edge_link() doesn't seem to be working. Here's a reprex:

nodes = tibble::tibble(id=1:2, x=c(1,2), y=c(1,2), name=c('A', 'B'))
edges = tibble::tibble(from=1, to=2, lab = 'italic(B) == 1.04')

tidygraph::tbl_graph(nodes = nodes, edges = edges, directed=TRUE, node_key = 'id') %>%
	ggraph::ggraph(layout='manual', x=x, y=y) + 
	ggraph::geom_edge_link(ggplot2::aes(label=lab), label_parse = TRUE, angle_calc = 'along', label_dodge = grid::unit(2.5, 'mm')) + 
	ggraph::geom_node_label(ggplot2::aes(label=name)) 

Digging into the code a tiny bit, it looks like the label_parse argument for all of the edge geoms gets processed as part of the creating the ggproto GeomEdgePath in the file geom_edge.R. If I'm reading it correctly, starting on line 125, it checks to see if label_parse is set to TRUE, and if so, parses the labels to expressions, saving the result as the variable lab_expressions. But then I can't see where lab_expressions is used anywhere else. Is that an oversight, or am I misunderstanding the code?

Activity

  1. tarball11 commented on Nov 12, 2020

    @tarball11
    Author
  2. added a commit that references this issue on Jun 23, 2025
    8e60310
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