Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
crossfading between raster layers in gganimate
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
You can’t perform that action at this time.