VennPlot: Draw A Venn Plot With Proportional Areas

Description Usage Arguments Details Value Author(s) See Also

View source: R/VennPlot.R

Description

VennPlot draws a Venn diagram based on the overlap of three sets, where the area are proportional to the size of each set an the overlaps approximate the relative overlap to the extent possible.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
VennPlot(
  set1,
  set2,
  set3 = vector(),
  labels = paste("Set", 1:3),
  lwd = 2,
  cex.text = 1,
  col = c("blue", "green", "red"),
  mar = rep(1, 4),
  main = "",
  cex.main = 1.2,
  labels.at = NA,
  xscale = 1.01,
  yscale = 1.01,
  return.sets = FALSE
)

Arguments

set1

Either a vector of identifiers (may be numeric or text) to define a single set, or a list of two or three such vectors. If set is a list, the names of the elements will be used as the names if the labels argument (below) is not supplied. Also, if set1 is a list, all remaining arguments must be named. Only the unique values in each set will be counted (replicate values will be removed).

set2, set3

Vectors of identifiers; may be numeric or text. If set1 is a vector, set2 is required and set3 is optional. If set1 is a list, the set2 and set3 arguments will be ignored if supplied.

labels

Optional character vector with names of each set.

lwd

A number specifying line width of the circles.

cex.text

A number specifying character size for labels.

col

A character vector of named colors for each set; length should be equal to the number of sets.

mar

4-element vector of positive numbers specifying outer margin of plot.

main

A character string specifying title of plot.

cex.main

A number specifying font size to use for title

labels.at

If NA (default), or any of the values are NA, the function will attempt to place the labels automatically. If omitted, the user will be prompted to manual select locations by clicking on the plot.

Otherwise, a 2-row column matrix with x- and y- coordinates indicating placement of the set labels. Number of rows must equal number of sets. On subsequent calls, may be extracted from the "Circles" element of the list returned by this function: Circles[, c("x.label", "y.label")]

xscale, yscale

Numeric value that controls the range of the data shown. Default is 1.01; larger values will leave more space around the margins (sometimes useful for making labels fit), while smaller values could be used to remove extra space when the aspect ratio differs from one.

return.sets

Logical; if TRUE, return a data.frame with each unique item's assignment to an overlap region.

Details

Only the unique values in each set will be counted (replicate values will be removed). A plot will generated with overlapping circles approximating the overlap between the sets. (It is not always possible to accurately represent the overlap of three sets using circles.)

Labels for each set may be placed in one of three ways using the labels.at argument:

Value

Returns a list object with named elements:

Areas: data.frame specifying number of unique items in various regions of the Venn diagram and the midpoints of each region on the plot (i.e., where the labels are placed). Circles : data.frame with the centers (x and y) and radii of the circles for each set

Author(s)

M.W.Rowe, mwr.stats@gmail.com

See Also

par and plot.default give more detailed descriptions of the plotting parameters lwd, cex.text, col mar, main and cex.main.


mwrowe/microRutils documentation built on June 12, 2021, 2:41 p.m.