首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用rmarkdown渲染时的变化速度

使用rmarkdown渲染时的变化速度
EN

Stack Overflow用户
提问于 2018-02-28 06:48:20
回答 1查看 3.4K关注 0票数 2

我有一些ggplot对象是通过gganimate动画的,我想改变动画的速度。

这里有一个来自github的可复制的示例:https://github.com/dgrtwo/gganimate

代码语言:javascript
复制
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设置为不同的值,但是没有效果,而且帮助页面中不清楚。

代码语言:javascript
复制
gganimate(p, time = 0.1)

更新

interval似乎一般都能工作,但我仍然不清楚如何在Rmarkdown报告中完成这一工作。例如,如果我将下面的代码放在一个名为test.R的文件中,然后运行rmarkdown::render('test.R'),那么我的动画将以默认速度运行,而不是预期的增长速度。我将如何在rmarkdown::render的上下文中完成这个任务?我一直在尝试从这里寻找不同的东西:https://github.com/dgrtwo/gganimate/commit/3aa2064cdfff30feb2b00724ad757fd5a5a62621,但没有用。

代码语言:javascript
复制
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))
EN

回答 1

Stack Overflow用户

发布于 2018-02-28 06:59:48

我们需要设置interval选项:

代码语言:javascript
复制
gganimate(p, interval = 0.2)

来自动画软件包手册,请参阅ani.options

interval :设置动画时间间隔(单位为秒)的正数;默认值为1。

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/49023515

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档