Skip to content

Instantly share code, notes, and snippets.

@npjc
Last active September 10, 2015 21:12
Show Gist options
  • Save npjc/7983a9f297fa03994ead to your computer and use it in GitHub Desktop.
Save npjc/7983a9f297fa03994ead to your computer and use it in GitHub Desktop.
pacman::p_load(readr, dplyr, tidyr, ggplot2)
library(partitions)
n <- 5
vals <- as.vector(parts(n))
len <- length(vals) / n
part <- rep(1:len, each = n)
d <- data_frame(vals, part)
d <- d %>%
group_by(part) %>%
mutate(res = as.integer(as.factor(vals)),
el = row_number())
d <- d %>% group_by(part, res) %>%
mutate(out = n()) %>%
rowwise() %>%
mutate(size_out = ifelse(out == 1, 3, 1))
ggplot(d, aes(el, part, group = interaction(part,res), colour = factor(el))) +
geom_line(size = 12, alpha = 1, colour = "grey80") +
geom_point(size = 11, alpha = 1, colour = "grey80") +
geom_point(size = 8, alpha = .8) +
theme_minimal() +
scale_y_continuous(NULL, breaks = NULL) +
scale_x_continuous(NULL, breaks = NULL)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment