2017-05-18 3 views
3

Je voudrais ajouter un second cercle interne aux sommets actuels. Il devrait être proportionnel à une certaine variable.igraph R | Comment ajouter un deuxième cercle interne pour chaque noeud?

Voici un exemple: enter image description here

Je sais déjà comment faire pour le cercle principal, qui est, la taille du sommet.

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 

Des idées?

Répondre

3

Vous pouvez essayer

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

+0

trick Nice. Est-il possible de faire commencer les arêtes à partir de l'anneau externe? – fibar

+0

@fibar Oui, ajoutez simplement 'edge.lty =" blank "' au second. À l'état actuel, il recouvre un deuxième ensemble d'arêtes. – lukeA