Adjusting the node size in igraph using a matrix

后端 未结 1 348
陌清茗
陌清茗 2020-12-10 05:15

I have the following network diagram:

set.seed(1410)
df<-data.frame(
\"site.x\"=c(rep(\"a\",4),rep(\"b\",4),rep(\"c\",4),rep(\"d\",4)),
\"site.y\"=c(rep(c         


        
1条回答
  •  一整个雨季
    2020-12-10 06:02

    You could use

    node.size<-setNames(c(25, 15, 35, 5, 10, 5, 19, 44),c("a", "b","c", "d", "e", "f", "g", "h"))
    plot(df,layout=l,vertex.label=V(df)$names,
    edge.arrow.size=0.01,vertex.label.color = "black",vertex.size=node.size)
    

    so basically a named vector.

    plot(df,layout=l,vertex.label=V(df)$names,
    edge.arrow.size=0.01,vertex.label.color = "black",vertex.size=as.matrix(node.size) )
    

    would also work

    enter image description here

    UPDATE:

    If you need to use your m matrix

    plot(df,layout=l,vertex.label=V(df)$names,
    edge.arrow.size=0.01,vertex.label.color = "black",vertex.size=m[m!=0]) 
    

    0 讨论(0)
提交回复
热议问题