【问题标题】:End Animation after Appearing出现后结束动画
【发布时间】:2021-07-23 03:17:09
【问题描述】:

我根据我的数据制作了一个动画,并设法为它提供了一个很好的抓图/分辨率,用于演示文稿。

我希望条形图中的条出现然后结束动画。我在 gganimate 中找不到正确的设置来使动画仅在一个方向上运行(仅显示)。

    a <- data.frame(group = c("sehr schlecht",
                          "schlecht",
                          "weder noch",
                          "gut",
                          "sehr gut"),
                values = c(0, 0, 0, 0, 0),
                frame = rep("a", 5))

b <- data.frame(group = c("sehr schlecht",
                          "schlecht",
                          "weder noch",
                          "gut",
                          "sehr gut"),
                values = c(20,
                          40,
                          20,
                          5,
                          15),
                frame = rep("b", 5))

graphdata <- rbind(a,b)  

p <- ggplot(graphdata, aes(x=group, y=values, fill=group)) + 
  geom_bar(stat='identity') +
  ylim(0, 100) +
  theme_bw() +
  theme(legend.title=element_blank()) +
  scale_x_discrete(name ="Anteil (%)", 
                   limits=c("sehr schlecht",
                            "schlecht",
                            "weder noch",
                            "gut",
                            "sehr gut")) +
  # gganimate specific bits:
  transition_states(
    frame,
    transition_length = 2,
    state_length = 1
  ) +
  ease_aes('sine-in-out')

options(gganimate.dev_args = list(width = 800, height = 600, res = 150))
                           
animate(p + enter_appear(),
  renderer = av_renderer()
)

【问题讨论】:

    标签: r gganimate


    【解决方案1】:

    好的,我自己找到了!在动画运行后结束动画可以使用转换状态(wrap = FALSE)进行切换:

      # gganimate specific bits:
      transition_states(
        frame,
        transition_length = 2,
        state_length = 1,
        wrap = FALSE
      ) +
      ease_aes('sine-in-out')
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2022-07-29
      • 2016-02-23
      • 1970-01-01
      • 2018-08-01
      • 2013-06-21
      • 2015-06-01
      • 1970-01-01
      相关资源
      最近更新 更多