Thanks to visit codestin.com
Credit goes to github.com

Skip to content

geom_edge_parallel fails with labels #227

@Ax3man

Description

@Ax3man

Adding labels to geom_edge_parallel causes some edges to collapse onto each other.

(Perhaps labels and parallel edges are not a great idea, but it could be nice to display two edges in opposing directions, instead of using arcs.)

Reprex:

library(ggraph)
library(tidygraph)

gr <- create_notable('bull') %>%
  convert(to_directed) %>%
  bind_edges(data.frame(from = c(1, 2, 2, 3), to = c(2, 1, 3, 2))) %E>%
  mutate(class = sample(letters[1:3], 9, TRUE)) %N>%
  mutate(class = sample(c('x', 'y'), 5, TRUE))

ggraph(gr, 'stress') +
  geom_edge_parallel()

ggraph(gr, 'stress') +
  geom_edge_parallel(
    aes(label = 1), 
    angle_calc = 'along', label_dodge = grid::unit(20, 'points')
  )

The first works fine:

image

But for the second (with labels), there are edges that are now on top of each other again.

image

(P.S.: You can also see that label_dodge appears to be calculated from middle of the group of edges, and not each individual edge, but this may be difficult to fix.)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions