gpt4 book ai didi

r - R中带有内部标签的三向维恩图

转载 作者:行者123 更新时间:2023-12-04 12:50:44 25 4
gpt4 key购买 nike

我一直在寻找如何通过以编程方式显示内部标签(重叠项)来绘制维恩图。代码中没有错误,但我仍然不知道如何解决这个问题。

维恩图

  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)

enter image description here

最佳答案

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)

enter image description here

关于r - R中带有内部标签的三向维恩图,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50360769/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com