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

How to set the speed of the animation in R?

我在 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()

可能重复:

无论如何,我认为这可以满足您的需求,如果您稍微玩一下 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)