colors - How can I create a fine colour scale in R, for plotting node colour with igraph? -


i using igraph plot small network (21 nodes) on r. nodes coloured according vector postmean, has values:

[1] -0.035275268  0.016065216 -0.009860104 -0.110333756  0.027173563  [6]  0.003732149 -0.015728577 -0.015447753 -0.015458429 -0.031747722  [11]  0.050184673  0.052410534  0.025986002  0.059460753  0.044158671  [16] -0.302219356  0.065311113  0.012006393  0.019186883 -0.006812400  [21]  0.196030557 

how can adjust scale of colours indicate values of postmean vector, when numbers small? fine gray-scale, seem able @ moment nodes white , nodes black.

many in advance.

you can use rescale() function plotrix package rescale vector 0 1, use gray() function convert these gray scale colors.

library(igraph) library(plotrix) vcol <- gray(rescale(postmean, c(0, 1))) tkplot(graph, vertex.color=vcol) 

if don't want range of colors extend way black , white, can reduce range of values rescale to, example:

vcol <- gray(rescale(postmean, c(0.1, 0.9))) 

Comments