【发布时间】:2018-11-11 14:16:47
【问题描述】:
(Here 与我的问题类似。我正在使用@Slow loris 在他的优秀答案中提供的示例)
我正在尝试绘制igraph 社区,但仅突出显示选定的社区。我该怎么做?
library(igraph)
# Generate random graph and community structure
set.seed(23)
temp <- sample_gnm(15, 45)
wctemp <- walktrap.community(temp)
# Plot
par(mfrow=c(1,2), mar=rep(1,4))
layout <-layout.fruchterman.reingold(temp)
plot(wctemp, temp, layout=layout, vertex.label=NA, vertex.size=5, edge.arrow.size=.2)
# Change colors of nodes, polygons, and polygon borders
new_cols <- c("white", "red", "black")[membership(wctemp)]
plot(wctemp, temp, col=new_cols, mark.border="black", mark.col=c("tan", "pink", "lightgray"),
layout=layout, vertex.label=NA, vertex.size=5, edge.arrow.size=.2)
在这个例子中,我改变了可以改变社区的颜色,但没有选择要突出显示的社区。预期的解决方案仅突出显示选定的社区,例如第一个和第三个社区。有需要吗?
【问题讨论】: