setwd("D:/R files/CFY-R-code/11.简单动态图")
library(pacman)
p_load(ggplot2, gganimate, ggthemr, gapminder, gifski)
ggthemr("flat dark")
g <- ggplot(gapminder, aes(gdpPercap, lifeExp, size = pop, color = continent)) +
geom_point() +
scale_x_log10() +
# gganimate specific bits:
labs(title = 'Year: {frame_time}', x = 'GDP per capita', y = 'life expectancy') +
transition_time(year) +
ease_aes('linear')
animate(g, renderer = gifski_renderer())
anim_save("9966.gif")