Venn diagram for non-numeric entries to be shown in subsets

試著忘記壹切 提交于 2021-01-27 22:32:02

问题


I have the folowing dataframe:

SET1 SET2 SET3
par1 par2 par1
par2 par3 par2
par3 par4 par5
...  ...  ...

I would like to make a Venn diagram in that all those 'parX' elements are shown in respective subets i.e. as labels, not just the number of overlapping elements. Which R package supports that?


回答1:


Regarding the best answer from here you have to add labels manually (using VennDiagram), when you have two circles it's pretty easy, however if you have three or more, whole stuff becames more complex

library(VennDiagram)



SET1 <- c('a','b','c','d')
SET2 <- c('a','e','f','g')
SET3 <- c('a','w','x','f')



v <- venn.diagram(list(SET1 = SET1, SET2 = SET2, SET3 = SET3),
                  fill = c("red", "green","blue"),
                  alpha = c(0.5, 0.5, 0.5), cat.cex = 1.5, cex=1.5,
                  filename=NULL)
grid.newpage()
grid.draw(v)


v[[7]]$label  <- paste(setdiff(SET1, intersect(SET2,SET3)), collapse="\n") 
v[[8]]$label <- paste(setdiff(intersect(SET1,SET2),intersect(SET1, intersect(SET2,SET3))), collapse="\n")
v[[9]]$label <- paste(setdiff(SET2, intersect(SET1,SET3)), collapse="\n")
v[[10]]$label <- paste(setdiff(intersect(SET3,SET1),intersect(SET3, intersect(SET1,SET2))), collapse="\n")
v[[11]]$label <- paste(intersect(SET1, intersect(SET2,SET3)), collapse="\n")
v[[12]]$label <- paste(setdiff(intersect(SET2,SET3),intersect(SET2, intersect(SET1,SET3))), collapse="\n")
v[[13]]$label <- paste(setdiff(SET3, intersect(SET1,SET2)), collapse="\n")


grid.newpage()
grid.draw(v)



来源:https://stackoverflow.com/questions/54363499/venn-diagram-for-non-numeric-entries-to-be-shown-in-subsets

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!