美文网首页
R语言gganimate动态图(二)

R语言gganimate动态图(二)

作者: Whuer_deng | 来源:发表于2019-06-18 19:32 被阅读0次

R语言gganimate动态图(一)

library(gapminder)
library(dplyr)
library(gganimate)
gapminder %>% 
  ggplot(aes(x = gdpPercap, y = lifeExp, size = pop, color = continent)) + 
  geom_point() + 
  scale_x_log10() + 
  transition_manual(frames = year) + 
  ggdark::dark_theme_bw() + #设置黑色主题
  labs(title = paste('Year:', '{current_frame}'))#设置标题跟随当前的年份变化,即current_frame。
动态图.gif
gganimate的transition_*函数有很多个,就测试而言,transition_manual()的运行速度最快,transition_time()的速度很慢,容易把电脑跑死。
image.png

相关文章

网友评论

      本文标题:R语言gganimate动态图(二)

      本文链接:https://www.haomeiwen.com/subject/zluqqctx.html