使用format()时,图形打印的标签向右移动 请考虑以下 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)) g
与使用format()时,图形打印的标签向右移动 请考虑以下 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)) g,plot,igraph,Plot,Igraph,与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
的关系比与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"