其他分享
首页 > 其他分享> > 【学习笔记】R语言生成GIF动态图

【学习笔记】R语言生成GIF动态图

作者:互联网

上代码:

library(ggplot2)
library(gganimate)
library(gifski)
library(av)
theme_set(theme_bw())

#臂架1&2角度动态图
p <- ggplot(
  mydata_stress, mapping = aes(
    x=X, 
    y=Arm1Arm2An))+
  geom_line(color="blue") +
  scale_color_viridis_d() +
  labs(x = "时间线", y = "臂架1&2角度",color="red") 
theme(legend.position = "top",axis.text.x = element_text(angle = 90,hjust = 1,vjust = .5))  #静态绘图

p+transition_reveal(X)
anim_save("gif_angle12.gif")

#臂架2&3角度动态图
p <- ggplot(
  mydata_stress, mapping = aes(
    x=X, 
    y=Arm2Arm3An))+
  geom_line(color="blue") +
  scale_color_viridis_d() +
  labs(x = "时间线", y = "臂架2&3角度") 
theme(legend.position = "top",axis.text.x = element_text(angle = 90,hjust = 1,vjust = .5))  #静态绘图

p+transition_reveal(X)
anim_save("gif_angle23.gif")

gganimate是生成动态图的包.

看下面链接应该够了:R语言gganimate动态图_Whuer-deng的博客-CSDN博客_gganimate

标签:gganimate,博客,library,生成,GIF,theme,笔记,动态图
来源: https://blog.csdn.net/Rickyzhangchanghong/article/details/122845759