How can I remove zero labels from a VennDiagram?

1.1k Views Asked by At

I have a Venn Diagram comparing five groups that have different sizes. Some of them does not share any element in common, for those the zero value appears inside the connections. However, I would like to remove the zero values labels so that the shared values are the only values displaying. Does anyone know how to do it? Also, is there anyway to remove the black outline? Thank you.

# Load the VennDiagram package
library(VennDiagram)

# Creating the set of number of conditions in common across studies
S1 <- c(1:11, "A")
S2 <- c(1:37, "A", "B", "C")
S3 <- c(1:58, "D", "E")
S4 <- c(1:36, "A", "B")
S5 <- as.character(c(1:306))
colors <- c("#6b7fff", "#c3db0f", "#ff4059", "#2cff21", "#de4dff")

# Make Venn diagram from list of groups
venn.diagram(x = list(S1, S2, S3, S4, S5) ,
             category.names = c("S1", "S2", "S3", "S4", "S5"),
             filename = 'venn_diagram.png',
             output=TRUE,
             imagetype="png", 
             scaled = TRUE,
             col = "black",
             fill = colors,
             cat.col = colors,
             cat.cex = 2,
             margin = 0.15
)

# Display saved image
options(repr.plot.height=12, repr.plot.width= 12)
library("png")
pp <- readPNG("venn_diagram.png")
plot.new() 
rasterImage(pp,0,0,1.1,1.1)

enter image description here

1

There are 1 best solutions below

1
On

I have not found any way to hide a label in the documentation or in the source code. According to the documentation, the way to control the outline is through the lwd option:

...
cat.col = colors,
cat.cex = 2,
margin = 0.15,
lwd = 0
...

In my system, there is still a faint line in the final picture. There are other packages that can give you something along the lines of your question. With my own package, called nVennR:

library(nVennR)
S1 <- c(1:11, "A")
S2 <- c(1:37, "A", "B", "C")
S3 <- c(1:58, "D", "E")
S4 <- c(1:36, "A", "B")
S5 <- as.character(c(1:306))
colors <- c("#6b7fff", "#c3db0f", "#ff4059", "#2cff21", "#de4dff")
myV <- plotVenn(list(S1=S1, S2=S2, S3=S3, S4=S4, S5=S5), setColors=colors, borderWidth=0)

This diagram is a little extreme. You can see Set1 only as a change in the color of the sets whose description (the vector inside the parentheses) includes 1, i. e., (1,2,3,4,5) and (1,2,4).

enter image description here