Last active
April 3, 2020 13:24
-
-
Save trinker/31edc08d0a4ec4c73935a23040c2f6cb to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if (!require("pacman")) install.packages("pacman") | |
pacman::p_load(dplyr, venneuler) | |
pacman::p_load_current_gh('trinker/textshape', 'thomasp85/ggforce') | |
x <- matrix(sample(0:4, 80, TRUE, c(.6, .1, .1, .1, .1)), ncol=4) | |
colnames(x) <- LETTERS[1:4] | |
euler_dat <- split(as.data.frame(x), c(T, F)) %>% | |
setNames( c('dog', 'cat')) %>% | |
lapply(function(x){ rownames(x) <- letters[1:10]; x}) %>% | |
lapply(function(x){ | |
y <- venneuler(x) | |
data.frame(y$centers, diameters = y$diameters, labels = y$labels, stringsAsFactors = FALSE) | |
}) %>% | |
textshape::bind_list('animal') | |
euler_dat %>% | |
mutate(r = diameters/2) %>% | |
ggplot() + | |
geom_circle(aes(x0 = x, y0 = y, r = r, fill=labels), alpha = .5) + | |
facet_wrap(~animal) + | |
geom_text(aes(x = x, y = y, label = labels)) + | |
coord_fixed() |
Author
trinker
commented
Sep 30, 2016
•
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment