在R gganimate中制作动画时,如何保留以前的数据层?

在R gganimate中制作动画时,如何保留以前的数据层?,r,animation,ggplot2,gif,gganimate,R,Animation,Ggplot2,Gif,Gganimate,我正在使用ggplot和gganimate制作动画。 在gganimate的前一个版本中有一个选项“累积”,似乎新版本不支持此选项 代码如下: library(ggplot2) library(gganimate) x = data.frame(y = c(2000, 2001), x=c(1,2), z=c(3,4)) ggplot(x, aes(x,z))+geom_point() + transition_time(y) 这是可行的,但我想把第一个数据点保留在散点图上 我试图转换数据,

我正在使用ggplot和gganimate制作动画。 在gganimate的前一个版本中有一个选项“累积”,似乎新版本不支持此选项

代码如下:

library(ggplot2)
library(gganimate)

x = data.frame(y = c(2000, 2001), x=c(1,2), z=c(3,4))
ggplot(x, aes(x,z))+geom_point() + transition_time(y)
这是可行的,但我想把第一个数据点保留在散点图上

我试图转换数据,但没有帮助:

x1 = data.frame(y = c(2000, 2001, 2001), x=c(1,2,1), z=c(3,4,3))
ggplot(x1, aes(x,z))+geom_point() + transition_time(y)
shadow\u mark()
是否实现了您想要的行为

x = data.frame(y = c(2000, 2001, 2002), x=c(1,2,3), z=c(3,4,5))

p <- ggplot(x, aes(x, z)) +
  geom_point() +
  transition_time(y) +
  shadow_mark()

animate(p)
x=data.frame(y=c(200020012002),x=c(1,2,3),z=c(3,4,5))
P