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

上一篇:js中String和new String的区别


下一篇:域渗透:MS14-068