I am trying to work out how to create a Venn diagram using the VennDiagram package that keeps 0s in. At the moment I have the issue below where if there is not overlap between the groups the circle is removed rather than kept but with a 0 in it, which is a useful result for my work. I get a venn diagram that looks like this:
I created this with the following code:
library(VennDiagram)
set1 <- paste(rep("word_", 20) , sample(c(1:1000), 20, replace=T) , sep="")
set2 <- paste(rep("word_", 20) , sample(c(1:1000), 20, replace=T) , sep="")
set3 <- paste(rep("word_", 20) , sample(c(1:1000), 20, replace=T) , sep="")
library(RColorBrewer)
myCol <- brewer.pal(3, "Pastel2")
venn.diagram(
x = list(set1, set2, set3),
category.names = c("Set 1", "Set 2 ", "Set 3"),
filename = '#140_venn_diagramm.png',
output=TRUE,
)
What I actually want my graphs to look like is below (but with some of the groups being visibly 0 if that applies):
The code to create something like this is:
set1 <- paste(rep("word_", 200), sample(c(1:1000), 200, replace=T) , sep="")
set2 <- paste(rep("word_", 200), sample(c(1:1000), 200, replace=T) , sep="")
set3 <- paste(rep("word_", 200), sample(c(1:1000), 200, replace=T) , sep="")
library(RColorBrewer)
myCol <- brewer.pal(3, "Pastel2")
venn.diagram(
x = list(set1, set2, set3),
category.names = c("Set 1", "Set 2 ", "Set 3"),
filename = '#140_venn_diagramm.png',
output=TRUE,
)
Any advice on how to fix this would be greatly appreciated.
So I couldn't find a simple way of using the VennDiagram package to make this happen, however, you can use the ggvenn package.
For example:
library(ggvenn)
set.seed(23) # to make data repeatable
# data from your question
set1 <- paste(rep("word_", 20) , sample(c(1:1000), 20, replace=T) , sep="")
set2 <- paste(rep("word_", 20) , sample(c(1:1000), 20, replace=T) , sep="")
set3 <- paste(rep("word_", 20) , sample(c(1:1000), 20, replace=T) , sep="")
ggvenn(list(`Set 1` = set1, `Set 2` = set2, `Set 3` = set3)) # create diagram