Change node / vertex transparency in iGraph in R

I have a network that, when I draw it, has several overlapping nodes. I want to change the opacity of the colors so that you can see the nodes under the others when they overlap. See this video as an example: https://vimeo.com/52390053

I use iGraph for my stories. Here's a simplified version of the code:

 net1 <- graph.data.frame(myedgelist, vertices=nodeslist, directed = TRUE) g <- graph.adjacency(get.adjacency(net1)) V(g)$color <- nodeslist$colors #This is a set of specific colors corresponding to each node. They are in the format "skyblue3". (These plot correctly for me). E(g)$color <-"gray" plot.igraph(g) 

I cannot, however, find an option in iGraph to change the opacity of the node colors.

How can i do this? I thought maybe something like V(g)$alpha <- 0.8 , but it does nothing.

+6
source share
2 answers

You might want to try, for example. this is:

 library(igraph) set.seed(1) g <- barabasi.game(200) plot(g, vertex.color = adjustcolor("SkyBlue2", alpha.f = .5), vertex.label.color = adjustcolor("black", .5)) 

enter image description here

+9
source

How I find it easier to manage than the method provided by lukeA is to use rgb (). You can specify the color (from node, node frame, edge, etc.) through four channels: R, G, B and A (alpha):

 library(igraph) set.seed(1) g <- barabasi.game(200) plot(g, vertex.color = rgb(0,0,1,.5), vertex.label.color = rgb(0,0,0,.5)) 

enter image description here

Another advantage is that you can easily change the alpha (or color) to fit the vector. The example below is not entirely practical, but you understand how this can be used:

 library(igraph) set.seed(1) g <- barabasi.game(200) col.vec <- runif(200,0,1) alpha.vec <- runif(200,0,1) plot(g, vertex.color = rgb(0,0,col.vec,alpha.vec), vertex.label.color = rgb(0,0,0,.5)) 

enter image description here

+3
source

Source: https://habr.com/ru/post/987677/


All Articles