【学习笔记】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("g

你可能感兴趣的:(R语言学习,r语言,开发语言)