【问题标题】:igraph R | How to add a second internal circle for each node?igraph R |如何为每个节点添加第二个内圈?
【发布时间】:2017-05-18 08:07:08
【问题描述】:

我想为当前顶点添加第二个内部圆。它应该与某个变量成正比。

这里是一个例子:

我已经知道怎么做主圆,也就是顶点大小。

variable1 <- c(20,40,60) # this will define the size of the vertices
g1 <- graph(edges=c(1,2, 2,3, 3,1), n=3, directed=F)
V(g1)$size <- variable1 # this assigns the vertices size to the igraph object 'g1'
plot(g1)
variable2 <- c(10,20,30) # this would be needed for a second, internal circle, ideally in a different color

有什么想法吗?

【问题讨论】:

    标签: r plot nodes igraph


    【解决方案1】:

    你可以试试

    library(igraph)
    variable1 <- c(20,40,60) # this will define the size of the vertices
    variable2 <- c(10,20,30) # this would be needed for a second, internal circle, ideally in a different color
    g1 <- graph(edges=c(1,2, 2,3, 3,1), n=3, directed=F)
    V(g1)$size <- variable1 # this assigns the vertices size to the igraph object 'g1'
    coords <- layout.auto(g1)
    plot(g1, layout=coords, vertex.frame.color="orange", vertex.color=NA, vertex.label = NA)
    plot(g1, layout=coords, vertex.size=variable2, add=T, vertex.color="lightgray")
    

    【讨论】:

    • 不错的把戏。是否可以让边缘从外环开始?
    • @fibar 是的,只需将edge.lty="blank" 添加到第二个即可。就目前而言,它覆盖了第二组边缘。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-09-30
    相关资源
    最近更新 更多