2017-12-07 5 views
0

는 I 배열 번호 94의 var1있다. 정의 된 간격 (예 : 0.05 초)의 gif로 표시되도록하고 싶습니다. 가능하면 번호 줄을 추가하고 싶습니다. ===============================어떻게 번호 라인과 주문 번호의 배열을 보여주는 애니메이션을 만드는 방법?

:이 같은 그림 (물론, 애니메이션)을 볼 것으로 예상 =========================

COV1 = 2.34

---------- | --- ----------------------------------> cov1

_____ 2.34

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

난 그냥 몇 가지 플롯의 gganimate 패키지를 사용하여 성공하지만 나는 또한 플롯이 아닌 뭔가 ... animation 패키지 관련 어쩌면 뭔가를 애니메이션을 필요 실현?

감사합니다.

답변

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

관련 문제