Created
February 20, 2019 05:11
-
-
Save jebyrnes/8a45ad5ae5b06b0b1653bcede55ccf14 to your computer and use it in GitHub Desktop.
crossfading between raster layers in gganimate
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
library(ggplot2) | |
library(gganimate) | |
mygridstart <- tidyr::crossing(x = 1:10, y = 1:10) | |
mygrid <- rbind(mygridstart, mygridstart, mygridstart) | |
mygrid$rep <- sort(rep(1:3, nrow(mygrid)/3)) | |
mygrid$pointgroup <- rep(1:100, 3) | |
mygrid$f <- factor(sample(1:3, replace=TRUE, size = nrow(mygrid))) | |
ggplot(mygrid, | |
aes(x = x, y = y, color = f, fill = f, group = pointgroup)) + | |
geom_raster() + | |
transition_states(rep) + | |
enter_fade() + | |
exit_fade() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment