请考虑以下
g <- graph.ring(10)
V(g)$label[1:5] <- 10
V(g)$label[6:10] <- 100000000
plot(g, layout=layout.circle, vertex.label=format(V(g)$label, big.mark=",", scientific=FALSE))
输出
我想知道为什么前5个顶点的标签向右移动以及如何将它们带回节点的中心。
答案 0 :(得分:1)
与format
的关系多于igraph
:
format(V(g)$label, big.mark=",", scientific=FALSE)
# [1] " 10" " 10" " 10" " 10" " 10"
# [6] "100,000,000" "100,000,000" "100,000,000" "100,000,000" "100,000,000"
只需删除空格,标签就会居中:
sub("[ ]+", "", format(V(g)$label, big.mark=",", scientific=FALSE))
# [1] "10" "10" "10" "10" "10"
# [6] "100,000,000" "100,000,000" "100,000,000" "100,000,000" "100,000,000"