Created
November 28, 2018 04:36
-
-
Save alistaire47/2474d87fff05b8fa0813e4d9b977cb57 to your computer and use it in GitHub Desktop.
uptake gifs
This file contains hidden or 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(dplyr) | |
library(ggplot2) | |
library(gganimate) | |
### Horizontal rotation | |
p <- data_frame(x = c(-4, 0, 4), y = c(0, 3, 0), state = 1) %>% | |
bind_rows(mutate(., x = -x, state = 2)) %>% # frame flipped over y-axis | |
ggplot(aes(x, y, ymin = y, ymax = y + 1)) + | |
geom_ribbon() + | |
coord_equal() + | |
theme_void() + | |
transition_time(state) + | |
ease_aes('sine-in-out') | |
animate(p, nframes = 100, fps = 30, height = 250) | |
anim_save('uptake.gif') | |
### Vertical flip | |
p2 <- data_frame(x = c(-4, 0, 4), y = c(-1.5, 1.5, -1.5), state = 1) %>% | |
bind_rows(mutate(., y = -y, state = 2)) %>% # frame flipped over y-axis | |
bind_rows(mutate(slice(., seq(n() / 2)), state = 3)) %>% # back to start | |
ggplot(aes(x, y, ymin = y, ymax = y + 1)) + | |
geom_ribbon() + | |
coord_equal() + | |
theme_void() + | |
transition_time(state) + | |
ease_aes('quartic-in-out') | |
animate(p2, nframes = 100, fps = 30, height = 250) | |
### Flip both | |
p3 <- data_frame(x = c(-4, 0, 4), y = c(-1.5, 1.5, -1.5), state = 1) %>% | |
bind_rows(mutate(., x = -x, y = -y, state = 2)) %>% # frame flipped over y-axis | |
bind_rows(mutate(slice(., seq(n() / 2)), state = 3)) %>% # back to start | |
ggplot(aes(x, y, ymin = y, ymax = y + 1)) + | |
geom_ribbon() + | |
coord_equal() + | |
theme_void() + | |
transition_time(state) + | |
ease_aes('sine-in-out') | |
animate(p3, nframes = 100, fps = 30, height = 250) |
Author
alistaire47
commented
Nov 28, 2018
p <- data_frame(x = c(-2, 0, 2), y = c(0, 2, 0), state = 1) %>%
bind_rows(mutate(., x = -x, state = 2)) %>% # frame flipped over y-axis
ggplot(aes(x, y, ymin = y, ymax = y + 1)) +
geom_ribbon() +
coord_equal() +
theme_void() +
transition_time(state) +
ease_aes('sine-in-out')
animate(p, nframes = 60, fps = 30)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment