【问题标题】:How to make an animated plot to stop rolling back when reaching the last animation step?如何使动画情节在到达最后一个动画步骤时停止回滚?
【发布时间】:2021-03-13 14:30:58
【问题描述】:

这是我制作的动画情节的可重现示例:

library(tidyverse)
library(gganimate)

data.1 <-read.csv(text = "
Year, value
1970,0
1980,1500
1990,2300
2000,4000
2010,4200
2020,6000
")
  
ggplot(data = data.1 %>% mutate(Year=as.numeric(Year),
                                  value=as.numeric(value)), 
       mapping = aes(x = Year, 
                     y = value)) +
    geom_line() +
    transition_reveal(Year) 

动画还可以,但我想让它在达到可视化的最后一年时停止而不是回滚。 transition_reveal 可以做到这一点吗?

【问题讨论】:

    标签: r ggplot2 graph-visualization gganimate


    【解决方案1】:

    渲染 gif 时,您可以像这样设置 loop = FALSE

    animate(myplot, renderer = gifski_renderer(loop = FALSE))
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2018-07-31
      • 2021-07-21
      • 2016-03-27
      • 1970-01-01
      • 2016-08-12
      • 1970-01-01
      • 2015-01-15
      相关资源
      最近更新 更多