向链接多个节点的边添加边属性

时间:2021-03-12 20:05:07

标签: r igraph ggraph

我有一个图表如下 -

# dput output 

g <- structure(list(29, TRUE, c(0, 0, 0, 0, 1, 0, 2, 0, 0, 3, 4, 0, 
0, 0, 3, 3, 4, 4, 5, 0, 2, 4, 0, 0, 3, 4, 4, 6, 0, 0, 4, 0), 
    c(7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 13, 17, 18, 19, 20, 
    21, 22, 23, 17, 24, 12, 25, 26, 27, 22, 12, 28, 26, 22, 28, 
    8, 25), c(0, 1, 2, 3, 5, 7, 8, 11, 12, 13, 28, 19, 31, 22, 
    23, 29, 4, 20, 6, 9, 14, 15, 24, 30, 25, 10, 16, 17, 21, 
    26, 18, 27), c(0, 1, 30, 2, 3, 4, 5, 20, 25, 6, 10, 7, 8, 
    9, 11, 18, 12, 13, 14, 15, 28, 24, 16, 17, 19, 31, 21, 22, 
    27, 23, 29, 26), c(0, 16, 17, 19, 23, 30, 31, 32, 32, 32, 
    32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 
    32, 32, 32, 32, 32), c(0, 0, 0, 0, 0, 0, 0, 0, 1, 3, 4, 5, 
    6, 9, 11, 12, 13, 14, 16, 17, 18, 19, 20, 23, 24, 25, 27, 
    29, 30, 32), list(c(1, 0, 1), structure(list(), .Names = character(0)), 
        list(name = c("W", "C", "S", "LM", "F", "R", "V", "6492", 
        "6927", "7689", "7426", "6251", "6924", "6386", "5195", 
        "7984", "7267", "7877", "7615", "6768", "7814", "6648", 
        "4943", "7532", "8498", "8188", "6789", "6270", "4896"
        ), type = c(1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 
        0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)), list()), 
    <environment>), class = "igraph")

# and plot 

ggraph(g, layout='nicely')+geom_edge_link()+geom_node_point(aes(fill = as.factor(V(ep_loc_2016)$type)), shape=21, stroke=1)+theme(legend.position="none")

enter image description here

我现在想更改线型以反映两组红色节点 - 其中红色节点连接到 >1 个蓝色节点 = 虚线,红色节点连接到单个蓝色节点 = 实线。

欢迎 ggraph 中的任何想法。 谢谢

0 个答案:

没有答案
相关问题