答案 0 :(得分:4)
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)
答案 1 :(得分:1)
我修改了四维恩图的代码,并修复了一些问题 标签的实际位置有误,这是代码:
createVennDiagramsMarkers <- function (){
require(VennDiagram)
x <- list()
x$AA <- c("hi","foo", "bar","yep","woo","hoo")
x$BB <- c("baa","yep", "woo","yes")
x$CC <- c("yes","foo","hi","woo", "huh")
x$DD <- c("HI","foo","bar","woo", "lg")
v0 <<-venn.diagram(x, height=9000, width=9000,
col = c("red", "blue", "green", "yellow"),
fill = c("red", "blue", "green", "yellow"),
alpha = 0.5, filename = NULL)
overlaps <- calculate.overlap(x)
overlaps <- rev(overlaps)
posOverlap = as.numeric (gsub ("a","", (names (overlaps))))
for (i in 1:length(overlaps)){
pos = posOverlap \[i\]
v0\[\[pos+8\]\]$label <- paste(overlaps\[\[i\]\], collapse = "\n")
}
pdf("venn.pdf")
grid.draw(v0)
dev.off()
}
createVennDiagramsMarkers ()