gpt4 book ai didi

r - 图 R |如何为每个节点添加第二个内圈?

转载 作者:行者123 更新时间:2023-12-01 13:35:09 24 4
gpt4 key购买 nike

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

举个例子: 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

有什么想法吗?

最佳答案

你可以试试

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

关于r - 图 R |如何为每个节点添加第二个内圈?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44042019/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com