igraph R | 如何为每个节点添加第二个内部圆圈?

3
我想在当前的顶点上添加第二个内部圆。它应该与某个变量成比例。
这里是一个例子: enter image description here 我已经知道如何为主圆即顶点大小做到这一点。
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

任何想法?
1个回答

3

您可以尝试

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")

enter image description here


不错的技巧。是否可以使边缘从外部环开始? - fibar
@fibar 是的,只需在第二个中添加 edge.lty="blank" 即可。目前它会重叠第二组边缘。 - lukeA

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接