Reputation: 195
The colors are defined by community attributes, instead vertex attributes. I need both: changing the colors of the vertex according to some vertex characteristics, and coloring the polygons around the communities.
g <- sample_gnm(15, 45) %>%
set_vertex_attr("att", value = rep(1:3,c(6,4,5)))
wc <- walktrap.community(g)
layout <-layout.fruchterman.reingold(g)
plot(wc, g, layout=layout, vertex.label=NA, vertex.size=10, vertex.color=V(g)$att, edge.arrow.size=.2)
Upvotes: 2
Views: 871
Reputation: 37621
What you tried to set the vertex color vertex.color=V(g)$att
makes sense, but unfortunately does not work when plotting communities. Instead, use col=V(g)$att
to set the vertex color. If you need to change the color for the polygons, use mark.color
.
plot(wc, g, layout=layout, vertex.label=NA, mark.col=rainbow(5, alpha=0.3),
vertex.size=10, col=V(g)$att, edge.arrow.size=.2)
Upvotes: 3