library(ggvenn)
# use data.frame as input
d <- tibble(value = c(1, 2, 3, 5, 6, 7, 8, 9),
`Set 1` = c(TRUE, FALSE, TRUE, TRUE, FALSE, TRUE, FALSE, TRUE),
`Set 2` = c(TRUE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, TRUE),
`Set 3` = c(TRUE, TRUE, FALSE, FALSE, FALSE, FALSE, TRUE, TRUE),
`Set 4` = c(FALSE, FALSE, FALSE, FALSE, TRUE, TRUE, FALSE, FALSE))
# ggplot gramma
ggplot(d) +
geom_venn(aes(A = `Set 1`, B = `Set 2`)) +
coord_fixed() +
theme_void()
ggplot(d) +
geom_venn(aes(A = `Set 1`, B = `Set 2`, C = `Set 3`)) +
coord_fixed() +
theme_void()
ggplot(d) +
geom_venn(aes(A = `Set 1`, B = `Set 2`, C = `Set 3`, D = `Set 4`)) +
coord_fixed() +
theme_void()
# set fill color
ggplot(d) +
geom_venn(aes(A = `Set 1`, B = `Set 2`), fill_color = c("red", "blue")) +
coord_fixed() +
theme_void()
# hide percentage
ggplot(d) +
geom_venn(aes(A = `Set 1`, B = `Set 2`), show_percentage = FALSE) +
coord_fixed() +
theme_void()
# change precision of percentages
ggplot(d) +
geom_venn(aes(A = `Set 1`, B = `Set 2`), digits = 2) +
coord_fixed() +
theme_void()
# show elements instead of count/percentage
ggplot(d) +
geom_venn(aes(A = `Set 1`, B = `Set 2`, C = `Set 3`, D = `Set 4`, label = value)) +
coord_fixed() +
theme_void()
Run the code above in your browser using DataLab