fibar
fibar

Reputation: 179

igraph R | How to add a second internal circle for each node?

I would like to add a second, internal circle to the current vertices. It should be proportional to a certain variable.

Here an example: enter image description here

I already know how to do that for the main circle, that is, the vertex size.

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

Any ideas?

Upvotes: 3

Views: 218

Answers (1)

lukeA
lukeA

Reputation: 54237

You could try

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

Upvotes: 3

Related Questions