Skip to content

Instantly share code, notes, and snippets.

@jonocarroll
Created August 15, 2018 06:20
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jonocarroll/1aad0241a0b0047fa73479a60dcc1d99 to your computer and use it in GitHub Desktop.
Save jonocarroll/1aad0241a0b0047fa73479a60dcc1d99 to your computer and use it in GitHub Desktop.
Animated datasauRus
# 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