r - 如何在R中设置动画的速度?

标签 r animation ggplot2 gganimate

我在 R 中使用 gganimate 设置了一个动画。这个动画太快了。如何设置帧的速度?

显示下一个点时,这些点也会消失。是否有可能这些点被一一显示,所以最后我有一个完整的散点图?

我该如何解决这个问题?

这是迄今为止的测试数据和我的代码:

#Test data
ID  Weight  Color Time
A   27  Red 1
A   11  Red 2
A   37  Red 3
A   49  Red 4
A   10  Red 5
A   25  Blue 6
A   49  Blue 7
A   20  Blue 8
A   21  Blue 9
A   36  Blue 10
A   24  Green 11
A   32  Green 12
A   47  Green 13
A   35  Green 14
A   24  Green 15
A   49  Yellow 16
A   42  Yellow 17
A   39  Yellow 18
A   22  Yellow 19
A   47  Yellow 20

#R code
library(plyr)
library(tidyr)
library(dplyr)
library(ggplot2)
library(gganimate)

p <- ggplot(dataset, aes(x=Color, y=Weight)) + geom_point()

order <- as.numeric(dataset$Time)

p + 
transition_time(order) +
labs(title = "TIME: {frame_time}") + enter_fade()

最佳答案

可能重复:Control speed of a gganimation

无论如何,如果您稍微使用一下 fps 参数,我认为这可以满足您的要求:

p <- ggplot(dataset, aes(x=Color, y=Weight)) + geom_point()

order <- as.numeric(dataset$Time)

gif <- p + 
  transition_time(order) +
  labs(title = "TIME: {frame_time}") + enter_fade()
animate(gif, fps = 2)

关于r - 如何在R中设置动画的速度?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57992798/

相关文章:

swift - 在游戏过程中不断改变 SKShapeNode 的颜色属性 (Swift)

r - ggplot2, R 中的单条柱状图

r - 在 ggplot2 中,我想并排绘制 boxplot+dotplot

r - 如何根据r中的分类列更改highchart中折线图的颜色?

r - 循环遍历 R 中有序集的功能方法

r - data.table 内部的环境如何工作?

r - R 中的 difftime 生成 NA 值

r - 表1.9.2中的NA/NaN/Inf

javascript - jQuery animate 仅在动画期间更改不透明度

javascript - 如何为 css 更改添加动画时间