[R] igraph plot - vertex colors

Jakson A. Aquino jaksonaquino at gmail.com
Tue Dec 8 22:49:52 CET 2009


On Sun, Dec 06, 2009 at 04:34:18PM -0800, Brock Tibert wrote:
> I have successfully created and analyzed my network data.  I am
> new to R, and Network Analysis too, but I want to color my
> vertex based on some of the centrality measures calculated.  
> 
> Can someone point me in the right direction? Again, I am new to
> R, but given how powerful R appears to be, I figure this is
> probably pretty easy to do, I just wish I could figure it out.

Below is an example of how to do it. Suppose you have a igraph
object called g:

hc5 <- heat.colors(5)
g.bet <- betweenness(g)
g.bet.max <- max(g.bet)
vcolors <- 5 - round(4 *(g.bet / g.bet.max))
vcolors <- hc5[vcolors]
plot(g, vertex.color=vcolors, main = "Betweenness")

-- 
Jakson




More information about the R-help mailing list