I am using gganimate. Say I have this 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)
I have one question: how can I make the new points just appear as opposed to transitioning from the old ones? Put another way, I just want the new dots to appear at their final location and not have a transition. How should I modify the code?
The transitions are ultimately tied to each data point's group
. In your code, all the Day 1 data points are sharing a group, and so they appear from the old ones.
Give the points their own group (e.g. by using group = interaction(Month, Day)
) and it should work.
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)