我开始熟悉gganimate
gif,但我想进一步扩展我的 gif。
例如,我可以frame
在一个变量中添加一个变量,gganimate
但如果我想为添加全新层/几何/变量的过程设置动画怎么办?
这是一个标准gganimate
示例:
library(tidyverse)
library(gganimate)
p <- ggplot(mtcars, aes(x = hp, y = mpg, frame = cyl)) +
geom_point()
gg_animate(p)
但是,如果我想要 gif 动画怎么办:
# frame 1
ggplot(mtcars, aes(x = hp, y = mpg)) +
geom_point()
# frame 2
ggplot(mtcars, aes(x = hp, y = mpg)) +
geom_point(aes(color = factor(cyl)))
# frame 3
ggplot(mtcars, aes(x = hp, y = mpg)) +
geom_point(aes(color = factor(cyl), size = wt))
# frame 4
ggplot(mtcars, aes(x = hp, y = mpg)) +
geom_point(aes(color = factor(cyl), size = wt)) +
labs(title = "MTCARS")
这怎么可能实现?