如何在一个动画循环后停止 gganimate
How to stop gganimate after one loop of animation
动画循环一圈可以停止吗?
动画应执行到去年 2021 年,然后停止显示所有条形!
下面是带有 gganimate
的条形动画示例:
library(tidyverse)
library(gganimate)
year <- (2000:2021)
something <- mtcars$mpg[1:22]
df <- tibble(year,something)
p <- ggplot(df, aes(year, something))+
geom_col() +
geom_text(aes(label=something), vjust=-0.3, size=4)+
transition_states(year, transition_length = 5, state_length = 10) + shadow_mark() +
enter_grow() +
exit_fade(alpha = 1)+
labs(title = 'Year: {closest_state}',
subtitle = "Blabla",
caption = "bla")
animate(p, fps=8)
您可以在 gifski 渲染器中设置此选项。
animate(p, fps=8, renderer = gifski_renderer(loop = FALSE))
动画循环一圈可以停止吗?
动画应执行到去年 2021 年,然后停止显示所有条形!
下面是带有 gganimate
的条形动画示例:
library(tidyverse)
library(gganimate)
year <- (2000:2021)
something <- mtcars$mpg[1:22]
df <- tibble(year,something)
p <- ggplot(df, aes(year, something))+
geom_col() +
geom_text(aes(label=something), vjust=-0.3, size=4)+
transition_states(year, transition_length = 5, state_length = 10) + shadow_mark() +
enter_grow() +
exit_fade(alpha = 1)+
labs(title = 'Year: {closest_state}',
subtitle = "Blabla",
caption = "bla")
animate(p, fps=8)
您可以在 gifski 渲染器中设置此选项。
animate(p, fps=8, renderer = gifski_renderer(loop = FALSE))