我有一些ggplot
通过 动画的对象gganimate
,我想改变动画的速度。
这是来自 github 存储库的可重现示例:https ://github.com/dgrtwo/gganimate
library(gapminder)
library(ggplot2)
theme_set(theme_bw())
p <- ggplot(gapminder, aes(gdpPercap, lifeExp, size = pop, color = continent, frame = year)) +
geom_point() +
scale_x_log10()
library(gganimate)
gganimate(p)
此动画全程循环大约需要 12 秒。我怎样才能让它在 6 秒内循环完成?
我尝试设置time
为不同的值,但无济于事,并且从帮助页面中也不清楚。
gganimate(p, time = 0.1)
更新
这interval
似乎通常有效,但我仍然不清楚如何在 Rmarkdown 报告中完成这项工作。例如,如果我将下面的代码放在一个名为的文件中test.R
,然后运行rmarkdown::render('test.R')
我的动画以默认速度运行,而不是预期的增加速度。我将如何在以下情况下进行这项工作rmarkdown::render
?从这里看,我一直在尝试各种事情:https ://github.com/dgrtwo/gganimate/commit/3aa2064cdfff30feb2b00724ad757fd5a5a62621 ,但无济于事。
knitr::opts_chunk$set(message = FALSE, warning = FALSE, fig.show = 'animate')
library(gapminder)
library(ggplot2)
theme_set(theme_bw())
p <- ggplot(gapminder, aes(gdpPercap, lifeExp, size = pop, color = continent, frame = year)) +
geom_point() +
scale_x_log10()
library(gganimate)
capture.output(gganimate(p, interval = 0.2))