Last active
November 15, 2019 23:42
-
-
Save mjskay/8ecc1c58cb72b36cb4888257b8b00ddf to your computer and use it in GitHub Desktop.
Blinky quantile dotplot + hypothetical outcome plot
This file contains hidden or 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
| library(tidyverse) | |
| library(gganimate) | |
| library(tidybayes) # need latest vesion from github for geom_dotsh() | |
| k = 50 | |
| draws = tibble( | |
| x = qnorm(ppoints(k)), | |
| draw = sample(1:k, k) | |
| ) | |
| p = tibble( | |
| frame = 1:k, | |
| draws = list(draws) | |
| ) %>% | |
| unnest(draws) %>% | |
| ggplot(aes(x = x, y = 0)) + | |
| geom_dotsh(aes(fill = draw == frame, group = frame), shape = 21, orientation = "horizontal") + | |
| guides(fill = FALSE) + | |
| scale_fill_manual(values = c("gray75", "red")) + | |
| transition_manual(frame) + | |
| xlim(-2.5, 2.5) | |
| animate(p, fps = 4, type = "cairo", width = 600, height = 340) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment