[英]R igraph color vertices
I'm trying to make a connectogram using code that's worked for me before but for some reason I'm having issue with the color of the vertices我正在尝试使用以前为我工作的代码制作连接图,但由于某种原因我对顶点的颜色有疑问
plot(net, edge.width=sqrt(links$weight), edge.arrow.size=0,
edge.lty=1, arrow.mode=0, vertex.size=10,
vertex.label=nodes$Name, vertex.label.dist=1.3,
vertex.label.cex=1.2, vertex.label.degree=-pi/4,
vertex.color=nodes$Team, layout=layout_in_circle)
The error I'm getting is Error in symbols(x = coords[, 1], y = coords[, 2], bg = vertex.color, : invalid color name 'Biomarkers'
我得到的错误是
Error in symbols(x = coords[, 1], y = coords[, 2], bg = vertex.color, : invalid color name 'Biomarkers'
Biomarkers is one of the variables in the Teams column. Biomarkers 是 Teams 列中的变量之一。 I'm attaching figures that are generated when I take out the vertex.color piece, so I know the rest of it works, and when I get this error (ignore the label overlap, I'll fiddle with that later)
我附上了当我取出 vertex.color 块时生成的图形,所以我知道它的 rest 有效,当我得到这个错误时(忽略 label 重叠,我稍后会摆弄它)
This is the error message that you would get if nodes$Team
is a character variable, ie strings.这是如果
nodes$Team
是字符变量(即字符串)时您会收到的错误消息。 You can get around this by making Team into a factor variable.您可以通过将 Team 设为因子变量来解决这个问题。
nodes$Team=as.factor(nodes$Team)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.