我一直在寻找如何以编程方式显示内部标签(重叠项)来绘制维恩图。代码中没有错误,但是我仍然无法弄清楚该如何解决。
require(VennDiagram)
AA <- c("hi","foo", "bar","yep","woo","hoo")
BB <- c("baa","yep", "woo","yes")
CC <- c("yes","foo","hi","woo", "huh")
x <- list(AA=AA , BB=BB , CC=CC)
v0 <- venn.diagram( x, filename=NULL)
grid.draw(v0)
overlaps <- calculate.overlap(x)
#overlaps <- rev(overlaps)
for (i in 1:length(overlaps)){
v0[[i+6]]$label <- paste(overlaps[[i]], collapse = "\n") # labels start at position 7 in the list for Venn's with 3 circles
}
grid.newpage()
grid.draw(v0)
Run Code Online (Sandbox Code Playgroud)
require(VennDiagram)
AA <- c("hi","foo", "bar","yep","woo","hoo")
BB <- c("baa","yep", "woo","yes")
CC <- c("yes","foo","hi","woo", "huh")
x <- list(AA=AA , BB=BB , CC=CC)
v0 <- venn.diagram( x, filename=NULL,
fill = c("red", "blue", "green"),
alpha = 0.50,
col = "transparent")
grid.draw(v0)
overlaps <- calculate.overlap(x)
# extract indexes of overlaps from list names
indx <- as.numeric(substr(names(overlaps),2,2))
# labels start at position 7 in the list for Venn's with 3 circles
for (i in 1:length(overlaps)){
v0[[6 + indx[i] ]]$label <- paste(overlaps[[i]], collapse = "\n")
}
grid.newpage()
grid.draw(v0)
Run Code Online (Sandbox Code Playgroud)