Created
August 15, 2018 06:20
-
-
Save jonocarroll/1aad0241a0b0047fa73479a60dcc1d99 to your computer and use it in GitHub Desktop.
Animated datasauRus
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
# modified from https://gist.github.com/sa-lee/c271b47d8065412d3d42c1ad8e63048d | |
library(datasauRus) | |
library(gganimate) | |
library(magrittr) | |
p <- datasaurus_dozen %>% | |
ggplot() + | |
geom_point(aes(x = x, y = y), col = "steelblue") + | |
theme(legend.position = 'none', | |
aspect.ratio = 1, | |
axis.title = element_blank(), | |
axis.text = element_blank(), | |
axis.ticks = element_blank()) | |
in_space <- p + facet_wrap(~dataset) | |
in_time <- p + | |
transition_states(dataset, 1, 1) + | |
labs(title = "dataset: {closest_state}") + | |
ease_aes('linear') | |
animate(in_time, | |
nframes = 300, detail = 2, fps = 12, | |
width = 300, height = 300) | |
anim_save(filename = "~/Pictures/datasaurus.gif") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment