Reputation: 2022
I previously asked this question:
https://stats.stackexchange.com/questions/139490/approach-and-example-of-graph-clustering-in-r
In the answer the code for coloring the graph was:
#make colors for different communities
V(g)$color <- ifelse(membership(fc)==1,"red","blue")
plot(g)
If I have 7 levels instead of 2, then I would like 7 different colors.
Is there a clean way, not manually enumeration, to use something like "matlab::jet.colors" to assign a unique color to each level of fc?
Upvotes: 1
Views: 23
Reputation: 37641
I think that you want
V(g)$color <- matlab::jet.colors(7)[membership(fc)]
Or maybe better
V(g)$color <- matlab::jet.colors(length(levels(membership(fc))))[membership(fc)]
Upvotes: 2