如何使 gganimate 中的点出现而不是过渡
How to make dots in gganimate appear and not transition
我正在使用 gganimate。假设我有这个 MWE:
library(ggplot2)
library(gganimate)
ggplot(airquality, aes(Day, Temp)) +
geom_point(color = 'red', size = 1) +
transition_time(Month) +
shadow_mark(colour = 'black', size = 0.75)
我有一个问题:我怎样才能让新点出现而不是从旧点过渡?换句话说,我只希望新点出现在它们的最终位置并且没有过渡。我该如何修改代码?
转换最终与每个数据点的 group
相关联。在您的代码中,所有第 1 天的数据点都共享一个组,因此它们出现在旧数据点中。
给点他们自己的组(例如通过使用 group = interaction(Month, Day)
),它应该有效。
a <- ggplot(airquality, aes(Day, Temp,
group = interaction(Month, Day))) +
geom_point(color = 'red', size = 1) +
transition_time(Month) +
shadow_mark(colour = 'black', size = 0.75) +
enter_fade() # I liked the look of this, but fine to leave out
animate(a, nframes = 100)
我正在使用 gganimate。假设我有这个 MWE:
library(ggplot2)
library(gganimate)
ggplot(airquality, aes(Day, Temp)) +
geom_point(color = 'red', size = 1) +
transition_time(Month) +
shadow_mark(colour = 'black', size = 0.75)
我有一个问题:我怎样才能让新点出现而不是从旧点过渡?换句话说,我只希望新点出现在它们的最终位置并且没有过渡。我该如何修改代码?
转换最终与每个数据点的 group
相关联。在您的代码中,所有第 1 天的数据点都共享一个组,因此它们出现在旧数据点中。
给点他们自己的组(例如通过使用 group = interaction(Month, Day)
),它应该有效。
a <- ggplot(airquality, aes(Day, Temp,
group = interaction(Month, Day))) +
geom_point(color = 'red', size = 1) +
transition_time(Month) +
shadow_mark(colour = 'black', size = 0.75) +
enter_fade() # I liked the look of this, but fine to leave out
animate(a, nframes = 100)