Last active
December 12, 2016 08:55
-
-
Save GuangchuangYu/690116374133be62c49d597aed0b1fa4 to your computer and use it in GitHub Desktop.
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
f <- function(a, b) function(y) a * y * log(y, base=10) -1/b * exp(-(b*y - b/exp(1))^4) | |
y <- seq(0, 1, length.out=100) | |
cols = colorspace::rainbow_hcl(5) | |
d1 <- data.frame(x = f(3, 30)(y), y=y, color=cols[1]) | |
d2 <- data.frame(x = f(2.8, 33)(y), y=y, color=cols[2]) | |
d3 <- data.frame(x = f(2.5, 36)(y), y=y, color=cols[3]) | |
d4 <- data.frame(x = f(2.2, 40)(y), y=y, color=cols[4]) | |
d5 <- data.frame(x = f(2, 50)(y), y=y, color=cols[5]) | |
df <- list(d1, d2, d3, d4, d5) | |
ggplot(rbind(d1,d2,d3,d4,d5)) + geom_path(aes(x, y, color=I(color))) + xlab(NULL) + ylab(NULL) | |
library(tweenr) | |
df2 <- tween_states(df, tweenlength=2, statelength=1, ease=rep('cubic-in-out', 4), nframes=100) | |
p <- ggplot(data=df2) + geom_path(aes(x, y, color=I(color), frame=.frame)) + xlab(NULL) + ylab(NULL) | |
animation::ani.options(interval = 1/24, ani.height=1000, ani.width=500) | |
gganimate::gganimate(p, 'breast.gif', title_frame = F) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment