出现后结束动画

End Animation after Appearing

我用我的数据制作了一个动画,并设法给它一个很好的 seize/resolution 用于 powerpoint 演示。

我希望条形图中的条出现,然后结束动画。我在 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()
)

好的,自己找的!在 运行 之后结束动画可以使用 t运行sitions 状态切换(wrap = FALSE):

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