CRAN version 1.13
This package produces Venn diagrams for up to seven sets, using any Boolean union of set intersections.
Install the stable version from CRAN:
install.packages("venn")
A simple Venn diagram with 3 sets
venn(3)
With a vector of counts: 1 for “000”, 2 for “001” etc.
venn(3, counts = 1:8)
Display the first whole set
venn("1--")
Same with
venn("A", snames = "A, B, C")
An equivalent command, from the union of all intersections
venn("100 + 110 + 101 + 111")
venn("A~B~C + AB~C + A~BC + ABC")
Adding the labels for the intersections
venn("1--", ilabels = TRUE)
Using different parameters for the borders
venn(4, lty = 5, col = "navyblue")
Using ellipses
venn(4, lty = 5, col = "navyblue", ellipse = TRUE)
A 5 sets Venn diagram
venn(5)
A 5 sets Venn diagram using ellipses
venn(5, ellipse = TRUE)
A 5 sets Venn diagram with intersection labels
venn(5, ilabels = TRUE)
And a predefined color style
venn(5, ilabels = TRUE, zcolor = "style")
A union of two sets
venn("1---- + ----1")
venn("A + E", snames = "A, B, C, D, E")
With different colors
venn("1---- , ----1", zcolor = "red, blue")
Same using SOP - sum of products notation
venn("A, E", snames = "A, B, C, D, E", zcolor = "red, blue")
Same colors for the borders
venn("1---- , ----1", zcolor = "red, blue", col = "red, blue")
A 6 sets diagram
venn(6)
Seven sets “Adelaide”
venn(7)
Artistic version
venn(c("1000000", "0100000", "0010000", "0001000", "0000100", "0000010", "0000001", "1111111"))
Without all borders
venn(c("1000000", "0100000", "0010000", "0001000", "0000100", "0000010", "0000001", "1111111"), borders = FALSE)
Using SOP - sum of products notation
venn("A + B~C", snames = "A, B, C, D")
The input can be a list
set.seed(12345) x <- list(First = 1:20, Second = 10:30, Third = sample(25:50, 15)) venn(x, ilabels = "counts")
Or a dataframe
set.seed(12345) x <- as.data.frame(matrix(sample(0:1, 150, replace = TRUE), ncol = 5)) venn(x, ilabels = "counts")
Using ggplot2 graphics
venn(x, ilabels = "counts", ggplot = TRUE)
Increasing the border size
venn(x, ilabels = "counts", ggplot = TRUE, size = 1.5)
With dashed lines
venn(x, ilabels = "counts", ggplot = TRUE, linetype = "dashed")
Venn diagrams for QCA objects
library(QCA) data(CVF) obj <- truthTable(CVF, "PROTEST", incl.cut = 0.85) venn(obj)
Custom labels for intersections
pCVF <- minimize(obj, include = "?") venn(pCVF$solution[[1]], zcol = "#ffdd77, #bb2020, #1188cc") cases <- paste(c("HungariansRom", "CatholicsNIreland", "AlbaniansFYROM", "RussiansEstonia"), collapse = "\n") coords <- unlist(getCentroid(getZones(pCVF$solution[[1]][2]))) text(coords[1], coords[2], labels = cases, cex = 0.85)
用于绘制维恩图和欧拉图的R语言包
版权所有:中国计算机学会技术支持:开源发展技术委员会 京ICP备13000930号-9 京公网安备 11010802047560号
Package venn
This package produces Venn diagrams for up to seven sets, using any Boolean union of set intersections.
Installation
Install the stable version from CRAN:
Examples
A simple Venn diagram with 3 sets
With a vector of counts: 1 for “000”, 2 for “001” etc.
Display the first whole set
Same with
An equivalent command, from the union of all intersections
Same with
Adding the labels for the intersections
Using different parameters for the borders
Using ellipses
A 5 sets Venn diagram
A 5 sets Venn diagram using ellipses
A 5 sets Venn diagram with intersection labels
And a predefined color style
A union of two sets
Same with
With different colors
Same using SOP - sum of products notation
Same colors for the borders
A 6 sets diagram
Seven sets “Adelaide”
Artistic version
Without all borders
Using SOP - sum of products notation
The input can be a list
Or a dataframe
Using ggplot2 graphics
Increasing the border size
With dashed lines
Venn diagrams for QCA objects
Custom labels for intersections