如何在大量的VennDiagram中加入逗号?

时间:2016-05-15 13:55:05

标签: r venn-diagram

我有一个使用VennDiagram包制作的维恩图。这些数字高于100,000。enter image description here

我希望谜语中的数字为150,001,逗号分隔符为15万,中间有一个小空格。这可能与VennDiagram有关吗?

这是我的例子

library(VennDiagram)
venn.diagram(x = list(A = 1:200000,B = 50000:300000), filename = "../example.tiff") 

1 个答案:

答案 0 :(得分:3)

我认为你不能轻易做到这一点。有两种打印模式rawpercent,但这些模式在函数中是硬编码的(请查看VennDiagram::draw.triple.venn)。您可以通过更改功能(我不喜欢)或手动调整grobs(在下面完成)来添加格式

library(VennDiagram)
p <- venn.diagram(x = list(A = 1:200000,B = 50000:300000), filename = NULL)

# Change labels for first three text grobs
# hard-coded three, but it would be the number of text labels
# minus the number of groups passed to venn.diagram
idx <- sapply(p, function(i) grepl("text", i$name))

for(i in 1:3){
  p[idx][[i]]$label <- 
           format(as.numeric(p[idx][[i]]$label), big.mark=",", scientific=FALSE)
}

grid.newpage()
grid.draw(p) 

enter image description here