MyNixOS website logo
Description

Draw Venn Diagrams.

A close to zero dependency package to draw and display Venn diagrams up to 7 sets, and any Boolean union of set intersections.

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:

install.packages("venn")

Examples

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")

Same with

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")

Same with

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)
Metadata

Version

1.12

License

Unknown

Platforms (75)

    Darwin
    FreeBSD 13
    Genode
    GHCJS
    Linux
    MMIXware
    NetBSD
    none
    OpenBSD
    Redox
    Solaris
    WASI
    Windows
Show all
  • aarch64-darwin
  • aarch64-genode
  • aarch64-linux
  • aarch64-netbsd
  • aarch64-none
  • aarch64_be-none
  • arm-none
  • armv5tel-linux
  • armv6l-linux
  • armv6l-netbsd
  • armv6l-none
  • armv7a-darwin
  • armv7a-linux
  • armv7a-netbsd
  • armv7l-linux
  • armv7l-netbsd
  • avr-none
  • i686-cygwin
  • i686-darwin
  • i686-freebsd13
  • i686-genode
  • i686-linux
  • i686-netbsd
  • i686-none
  • i686-openbsd
  • i686-windows
  • javascript-ghcjs
  • loongarch64-linux
  • m68k-linux
  • m68k-netbsd
  • m68k-none
  • microblaze-linux
  • microblaze-none
  • microblazeel-linux
  • microblazeel-none
  • mips-linux
  • mips-none
  • mips64-linux
  • mips64-none
  • mips64el-linux
  • mipsel-linux
  • mipsel-netbsd
  • mmix-mmixware
  • msp430-none
  • or1k-none
  • powerpc-netbsd
  • powerpc-none
  • powerpc64-linux
  • powerpc64le-linux
  • powerpcle-none
  • riscv32-linux
  • riscv32-netbsd
  • riscv32-none
  • riscv64-linux
  • riscv64-netbsd
  • riscv64-none
  • rx-none
  • s390-linux
  • s390-none
  • s390x-linux
  • s390x-none
  • vc4-none
  • wasm32-wasi
  • wasm64-wasi
  • x86_64-cygwin
  • x86_64-darwin
  • x86_64-freebsd13
  • x86_64-genode
  • x86_64-linux
  • x86_64-netbsd
  • x86_64-none
  • x86_64-openbsd
  • x86_64-redox
  • x86_64-solaris
  • x86_64-windows