Learn R Programming

VennDiagram (version 1.6.15)

draw.quad.venn: Draw a Venn Diagram with Four Sets

Description

Creates a Venn diagram with four sets.

Usage

draw.quad.venn(area1, area2, area3, area4, n12, n13, n14, n23, n24,
    n34, n123, n124, n134, n234, n1234, category = rep("",
    4), lwd = rep(2, 4), lty = rep("solid", 4), col =
    rep("black", 4), fill = NULL, alpha = rep(0.5, 4),
    label.col = rep("black", 15), cex = rep(1, 15),
    fontface = rep("plain", 15), fontfamily = rep("serif",
    15), cat.pos = c(-15, 15, 0, 0), cat.dist = c(0.22,
    0.22, 0.11, 0.11), cat.col = rep("black", 4), cat.cex
    = rep(1, 4), cat.fontface = rep("plain", 4),
    cat.fontfamily = rep("serif", 4), cat.just =
    rep(list(c(0.5, 0.5)), 4), rotation.degree = 0,
    rotation.centre = c(0.5, 0.5), ind = TRUE, cex.prop =
    NULL, print.mode = "raw", sigdigs = 3, direct.area =
    FALSE, area.vector = 0, ...)

Arguments

area1
The size of the first set
area2
The size of the second set
area3
The size of the third set
area4
The size of the fourth set
n12
The size of the intersection between the first and the second set
n13
The size of the intersection between the first and the third set
n14
The size of the intersection between the first and the fourth set
n23
The size of the intersection between the second and the third set
n24
The size of the intersection between the second and the fourth set
n34
The size of the intersection between the third and the fourth set
n123
The size of the intersection between the first, second and third sets
n124
The size of the intersection between the first, second and fourth sets
n134
The size of the intersection between the first, third and fourth sets
n234
The size of the intersection between the second, third and fourth sets
n1234
The size of the intersection between all four sets
category
A vector (length 4) of strings giving the category names of the sets
lwd
A vector (length 4) of numbers giving the line width of the circles' circumferences
lty
A vector (length 4) giving the dash pattern of the circles' circumferences
col
A vector (length 4) giving the colours of the circles' circumferences
fill
A vector (length 4) giving the colours of the circles' areas
alpha
A vector (length 4) giving the alpha transparency of the circles' areas
label.col
A vector (length 15) giving the colours of the areas' labels
cex
A vector (length 15) giving the size of the areas' labels
fontface
A vector (length 15) giving the fontface of the areas' labels
fontfamily
A vector (length 15) giving the fontfamily of the areas' labels
cat.pos
A vector (length 4) giving the positions (in degrees) of the category names along the circles, with 0 (default) at 12 o'clock
cat.dist
A vector (length 4) giving the distances (in npc units) of the category names from the edges of the circles (can be negative)
cat.cex
A vector (length 4) giving the size of the category names
cat.col
A vector (length 4) giving the colours of the category names
cat.fontface
A vector (length 4) giving the fontface of the category names
cat.fontfamily
A vector (length 4) giving the fontfamily of the category names
cat.just
List of 4 vectors of length 2 indicating horizontal and vertical justification of each category name
rotation.degree
Number of degrees to rotate the entire diagram
rotation.centre
A vector (length 2) indicating (x,y) of the rotation centre
ind
Boolean indicating whether the function is to automatically draw the diagram before returning the gList object or not
cex.prop
A function or string used to rescale areas
print.mode
Can be either 'raw' or 'percent'. This is the format that the numbers will be printed in. Can pass in a vector with the second element being printed under the first
sigdigs
If one of the elements in print.mode is 'percent', then this is how many significant digits will be kept
direct.area
If this is equal to true, then the vector passed into area.vector will be directly assigned to the areas of the corresponding regions. Only use this if you know which positions in the vector correspond to which regions in the diagram
area.vector
An argument to be used when direct.area is true. These are the areas of the corresponding regions in the Venn Diagram
...
Additional arguments to be passed, including margin, which indicates amount of whitespace around the final diagram in npc units

Value

  • Returns an object of class gList containing the grid objects that make up the diagram. Also displays the diagram in a graphical device unless specified with ind = FALSE. Grid::grid.draw can be used to draw the gList object in a graphical device.

Details

The function defaults to placing the ellipses so that area1 corresponds to lower left, area2 corresponds to lower right, area3 corresponds to middle left and area4 corresponds to middle right. Refer to the example below to see how the 31 partial areas are ordered. Arguments with length of 15 (label.col, cex, fontface, fontfamily) will follow the order in the example.

Examples

Run this code
# Reference four-set diagram
venn.plot <- draw.quad.venn(
	area1 = 72,
	area2 = 86,
	area3 = 50,
	area4 = 52,
	n12 = 44,
	n13 = 27,
	n14 = 32,
	n23 = 38,
	n24 = 32,
	n34 = 20,
	n123 = 18,
	n124 = 17,
	n134 = 11,
	n234 = 13,
	n1234 = 6,
	category = c("First", "Second", "Third", "Fourth"),
	fill = c("orange", "red", "green", "blue"),
	lty = "dashed",
	cex = 2,
	cat.cex = 2,
	cat.col = c("orange", "red", "green", "blue")
	);

# Writing to file
tiff(filename = "Quad_Venn_diagram.tiff", compression = "lzw");
grid.draw(venn.plot);
dev.off();

Run the code above in your browser using DataLab