我用我的数据制作了一个动画,并设法为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()
)
好的,我自己找到了!在动画运行后结束动画可以通过转换状态进行切换(wrap=FALSE(:
# gganimate specific bits:
transition_states(
frame,
transition_length = 2,
state_length = 1,
wrap = FALSE
) +
ease_aes('sine-in-out')