我正在开发一个小项目,涉及查找图形的社区结构和绘图。我使用 label.propagation.community 算法进行社区检测,并使用以下代码行进行绘图:
plot(community_1, graph_1)
问题在于图表显示的顶点标签使绘图看起来更拥挤。有什么办法可以从情节中去掉这些标签吗?我不想修改图表和社区中的任何内容;只是想告诉绘图不要打印标签。
最佳答案
对于像我这样在 igraph 图的属性深入研究时偶然发现这一点的人,可在此处找到 igraph
图中可用的 graph
属性的完整列表:http://kateto.net/networks-r-igraph
在第 5.1 节中,您会发现:
5.1 Plotting parameters
NODES
vertex.color Node color
vertex.frame.color Node border color
vertex.shape One of “none”, “circle”, “square”, “csquare”, “rectangle”
“crectangle”, “vrectangle”, “pie”, “raster”, or “sphere” vertex.size Size of the node (default is 15) vertex.size2 The second size of the node (e.g. for a rectangle)
vertex.label Character vector used to label the nodes
vertex.label.family Font family of the label (e.g.“Times”, “Helvetica”)
vertex.label.font Font: 1 plain, 2 bold, 3, italic, 4 bold italic, 5 symbol
vertex.label.cex Font size (multiplication factor, device-dependent)
vertex.label.dist Distance between the label and the vertex
vertex.label.degree The position of the label in relation to the vertex, where 0 right, “pi” is left, “pi/2” is below, and “-pi/2” is above
EDGES
edge.color Edge color
edge.width Edge width, defaults to 1
edge.arrow.size Arrow size, defaults to 1
edge.arrow.width Arrow width, defaults to 1
edge.lty Line type, could be 0 or “blank”, 1 or “solid”, 2 or “dashed”, 3 or “dotted”, 4 or “dotdash”, 5 or “longdash”, 6 or “twodash”
edge.label Character vector used to label edges
edge.label.family Font family of the label (e.g.“Times”, “Helvetica”)
edge.label.font Font: 1 plain, 2 bold, 3, italic, 4 bold italic, 5 symbol
edge.label.cex Font size for edge labels
edge.curved Edge curvature, range 0-1 (FALSE sets it to 0, TRUE to 0.5)
arrow.mode Vector specifying whether edges should have arrows, possible values: 0 no arrow, 1 back, 2 forward, 3 both
OTHER
margin Empty space margins around the plot, vector with length 4
frame if TRUE, the plot will be framed
main If set, adds a title to the plot
sub If set, adds a subtitle to the plot
由此,正如 @VincentGuillemot 所指出的,您可以使用 vertex.label
参数来操作节点标签。
要删除标签,您可以编写:
plot(community_1, graph_1, vertex.label=NA)
关于r - 删除 R 图中的顶点标签,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36976868/