Coloring vertexes according to their centrality

随声附和 提交于 2019-12-03 16:16:57

Seems like you already did most of the work. All you have to know is colorRamppalette and setting the vertex.color for the network. Assuming you have to change the colors linearly,

just do

fine = 500 # this will adjust the resolving power.
pal = colorRampPalette(c('red','green'))

#this gives you the colors you want for every point
graphCol = pal(fine)[as.numeric(cut(btw,breaks = fine))]

# now you just need to plot it with those colors
plot(adj, vertex.color=graphCol)

credits to this. I was using a much more inefficient method to assign the colors before answering this.

Ernest Aigner

Just a note:

It can be problematic to define

palette = colorRampPalette(c('blue','green'))

as the 'palette' function, is also used by igraph, and so igraph later produces as error.

See problem Color pallette for vertices in igraph network in R

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!