d3Venn: Create a d3 Venn diagram

Description Usage Arguments Details Value JavaScript Libraries See Also Examples

View source: R/d3Venn.R

Description

Draw a Venn diagram given a data frame with the sizes and names of the sets.

Usage

1
2
3
4
5
6
7
8
d3Venn(
  sets,
  fill_colors = NULL,
  text_color = NULL,
  center_text = FALSE,
  width = NULL,
  height = NULL
)

Arguments

sets

data.frame, each row correspond to one part in the Venn diagram. Must contain columns sets and size and may contain a column label. Intersections are represented by a list of set names.

fill_colors, text_color

character, vector of colors for filling the circles and the text respectively. Must be interpretable by css (see htmltools::parseCssColors() for allowed formats).

center_text

boolean, should the circles' texts be centered horizontally and vertically?

width

integer, width of the htmlwidget.

height

integer, height of the htmlwidget.

Details

To pass the size (and or label) of the intersections, the corresponding sets element must contain a list. To create list columns you can use base::I(). See Examples.

Value

an htmlwidget

JavaScript Libraries

See Also

htmlwidgets::createWidget()

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
# Venn diagram with 2 disjoint sets both of equal size
d3Venn(data.frame(sets = c("A", "B"), size = c(20, 20)))

# Venn diagram with 2 disjoint sets with differnt sizes and labels
d3Venn(data.frame(sets = c("A", "B"), size = c(10, 20), label = c("Set 1", "Set 2")))

# Venn diagram with 2 overlapping sets
d3Venn(data.frame(sets = I(list("A", "B", list("A", "B"))),
                  size = c(10, 10, 2)))

# Venn diagram where B is a subset of A
d3Venn(data.frame(sets = I(list("A", "B", list("A", "B"))),
                  size = c(20, 10, 10)))

# Venn diagram with differnt colors and centered text
d3Venn(data.frame(sets = I(list("A", "B", list("A", "B"))),
                  size = c(20, 20, 10)),
       c("cornflowerblue", "hsl(300, 100%, 70%)"),
       "#FFA500",
       TRUE)

thothal/d3Venn documentation built on Dec. 31, 2020, 8:38 a.m.