Created
November 1, 2021 00:37
-
-
Save thebioengineer/1a051cb2931763ec2da2d355fd8010bc to your computer and use it in GitHub Desktop.
Create a sample gif with camcorder
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
require(ggplot2) | |
library(ggimage) | |
if(!require(camcorder)){ | |
remotes::install_github("thebioengineer/camcorder") | |
library(camcorder) | |
} | |
gg_record() | |
for(word_size in seq(1,30)){ | |
gg <- ggplot(data.frame(x = 1, y = 1, label = "We live in a world..."), | |
aes(x=x, y=y, label = label)) + | |
geom_text(size = word_size, color = "white") + | |
theme_void() + | |
theme(legend.position = "none", | |
plot.background = element_rect(fill = "black")) | |
print(gg) | |
} | |
for(word_size in seq(1,5)){ | |
gg <- ggplot(data.frame(x = 1, y = 1, label = "Where"), | |
aes(x=x, y=y, label = label)) + | |
geom_text(size = 10, color = "white") + | |
theme_void() + | |
theme(legend.position = "none", | |
plot.background = element_rect(fill = "black")) | |
print(gg) | |
} | |
for(word_size in seq(1,5)){ | |
gg <- ggplot(data.frame(x = 1, y = 1, image = system.file("extdata/Rlogo.png",package = "ggimage")), | |
aes(x=x, y=y)) + | |
geom_image(aes(image = image), size = .5) + | |
theme_void() + | |
theme(legend.position = "none", | |
plot.background = element_rect(fill = "black")) | |
print(gg) | |
} | |
for(word_size in seq(1,5)){ | |
gg <- ggplot(data.frame(x = 1, y = 1, label = "Makes"), | |
aes(x=x, y=y, label = label)) + | |
geom_text(size = 10, color = "white") + | |
theme_void() + | |
theme(legend.position = "none", | |
plot.background = element_rect(fill = "black")) | |
print(gg) | |
} | |
for(word_size in seq(1,5)){ | |
gg <- ggplot(data.frame(x = 1, y = 1, label = "Movies"), | |
aes(x=x, y=y, label = label)) + | |
geom_text(size = 10, color = "white") + | |
theme_void() + | |
theme(legend.position = "none", | |
plot.background = element_rect(fill = "black")) | |
print(gg) | |
} | |
for(word_size in seq(1,30)){ | |
gg <- ggplot(data.frame(x = runif(400), y = runif(400), color = sample(rainbow(10),400,replace = TRUE))) + | |
geom_hex(aes(x=x, y=y, color = color, fill = color, | |
size = sample(c(.5,.75,1,2), 400, replace = TRUE, prob = c(3,10,2,1)))) + | |
geom_text(data = data.frame(x = .5, y = .5, label ="#rstats | @ellis_hughes"), | |
aes(x=x, y=y, label = label), | |
size = 10, color = "white",fontface = "bold") + | |
theme_void() + | |
theme(legend.position = "none", | |
plot.background = element_rect(fill = "black")) | |
print(gg) | |
} | |
gg_playback("R_Movie.gif",frame_duration = .1) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment