2017-12-07 10 views
0

私は配列番号var1の94の数字を持っています。定義された間隔(例:0.05秒)のgifで表示するようにします。可能であれば、番号の行を追加することもできます。 ===============================数字の並び順の配列を示すアニメーションを作成する方法は?

:私はこのような絵(もちろん、アニメーションを)見ることを期待します=========================

COV1 = 2.34

---------- | --- ----------------------------------> COV1

_____ 2.34

= ========================================== =====

たぶん... animationパッケージに関連する何かを私はいくつかのプロットのためのgganimateパッケージを使用することに成功したが、その後、私はまた、プロットではない何かをアニメーション化するために必要な実現?

ありがとうございます!

答えて

1

特に目立たないように見えますが(実際に見ると頭がおかしくなります)、アニメ化されています。

library(tidyverse) 
library(gganimate) 

set.seed(10) 
dat = data.frame(x=sort(runif(94, 0, 100))) 

p = ggplot(dat) + 
    geom_line(data=data.frame(y=rep(c(0.90,0.905,1.095,1.1),each=2), x=rep(range(dat$x), 4)), 
      aes(x,y,group=y), size=1, colour="grey40", linetype=2) + 
    geom_line(aes(x,y=1), colour="grey60", size=1.5, linetype="11") + 
    geom_text(aes(label=paste0("COV1\n", round(x,2)), x=x, y=1.05, frame=x), size=5) + 
    geom_segment(aes(x=min(dat$x), xend=x, y=1, yend=1, frame=x), 
       arrow=arrow(angle=90, length=unit(0.4, "cm")), size=1.5) + 
    scale_y_continuous(limits=c(0.8,1.1)) + 
    theme_void() + 
    theme(plot.title=element_blank()) 

gganimate(p, filename="my_gif.gif", interval=0.05) 

enter image description here

関連する問題