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

Background in edge labels #51

Open
thomasp85 opened this issue Feb 16, 2017 · 1 comment
Open

Background in edge labels #51

thomasp85 opened this issue Feb 16, 2017 · 1 comment
Labels

Comments

@thomasp85
Copy link
Owner

No description provided.

@zouter
Copy link

zouter commented Feb 2, 2018

For anyone visiting this page and wanting this functionality now: you can easily extract the edge position data and use the background functionality from geom_label.

graph <- tidygraph::as_tbl_graph(data.frame(from=1:10, to=sample(1:10, 15, T), label=sample(1:10, 20, T)))
ggraph(graph) +
  geom_edge_link() +
  geom_label(aes(x=(xend+x)/2, y = (yend+y)/2, label=label), get_edges()) +
  theme_graph()

You can also use geom_label_repel.

graph <- tidygraph::as_tbl_graph(data.frame(from=1:10, to=sample(1:10, 15, T), label=sample(1:10, 20, T)))
ggraph(graph) +
  geom_edge_link() +
  ggrepel::geom_label_repel(aes(x = (xend+x)/2, y = (yend+y)/2, label=label), get_edges()) +
  theme_graph()

This approach has issues however if the edges are arcs...

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

No branches or pull requests

2 participants