我有一个大型网络,以典型的方式为其分配了顶点形状和颜色。但是,我想分别绘制该网络的某些组件,并使图形颜色/形状信息正确分配给正确的节点。
我尝试了各种形式的vertex / color和vertex.shape,其中带有“ g”的子组件分别是“ dg [[1]]”“ dg [[2]]”等,但是当我检查信息时根据我的初始图,图显然没有为正确的节点提取正确的信息。帮助吗?
V(g)$color=gsub("A","red",V(g)$color)
V(g)$color=gsub("B","orange",V(g)$color)
V(g)$color=gsub("H","yellow",V(g)$color)
V(g)$color=gsub("W","green",V(g)$color)
V(g)$color=gsub("Z","blue", V(g)$color)
#assign "sex" to shape - M circles, F squares
V(g)$shape = "circle" #start by setting all shapes to a default of "circle"
V(g)$shape = ifelse(V(g)$sex =="F","square",V(g)$shape)
#Number of Components
dg <- decompose.graph(g)
table(sapply(dg, vcount))
#GET ALL THE COMPONENTS
graphslist<-list()
for(i in 1:55){
a<-dg[[i]]
graphslist[[i]] = a
print(graphslist[[i]])
}
#give the vertex size of each component
for(i in 1:55){
print(vcount(dg[[i]]))
}
#Plotting a component to check everything is still correctly assigned
plot(dg[[1]], layout=layout_with_kk,vertex.color=V(dg[[1]])$color,vertex.shape=V(dg[[1]])$shape)
例如,如果我说人B在我的原始图形g中应该是一个蓝色方块。当我绘制其中包含人B的子图时,它们应保持蓝色正方形。这没有发生,我不确定为什么。