Enrico Gabrielli
Enrico Gabrielli

Reputation: 31

hierarchical edge bundle ggraph: split "from" the second level connections

I have two graphs, the first graph is taxonomic, the second graph represents a second level of connections. The perfect graph is a hierarchical edge bundle. However, I need to keep the "from" of the second level of connections separate in the graph. My data:

hierarchy=data.frame(from=c("1","1","1","1","1.1","1.1","1.2","1.2","1.3","1.3","1.4","1.4"),
                    to=c("1.1","1.2","1.3","1.4","1.1.1","1.1.2","1.2.1","1.2.2","1.3.1","1.3.2","1.4.1","1.4.2"))
rel = data.frame(from=c("1.3.1","1.3.1","1.4.2","1.4.2"),
                 to=c("1.1.2","1.3.2","1.2.1","1.1.1"))

Normally the code to make a "hierarchical edge bundle" with "cactustree" layout is:

hierarchy_gr = as_tbl_graph(hierarchy)
vertices_hierarchy = hierarchy_gr %>% V()
from <- match( rel$from, vertices_hierarchy$name)
to <- match( rel$to, vertices_hierarchy$name)
ggraph(hierarchy_gr, 'cactustree',upright=TRUE) + 
#  geom_node_circle(aes(fill = depth), size = 0.25, alpha = 0.2) + 
  geom_conn_bundle(data = get_con(from = from, to = to), colour="red",linewidth=1,tension = 1) +
  geom_node_text(aes(label = name, size=0.5),check_overlap = TRUE) +
  theme(legend.position = "none") +
  coord_fixed()

and the result is: enter image description here

but I would something like this: enter image description here

Upvotes: 0

Views: 25

Answers (0)

Related Questions