I am trying to animate a scatter plot showing only the labels for the most recent dot.
What I am struggling with is to get the preceding labels disappear. I understand that 'closest_state' might be part of the answer, but as far as I can tell fading out preceding labels and keeping the preceding dots is not possible.
What I found is this, but I am struggling to implement it.
Any help? Many thanks!
library(tidyverse)
#> Warning: package 'dplyr' was built under R version 3.6.3
#> Warning: package 'forcats' was built under R version 3.6.3
library(gganimate)
#> Warning: package 'gganimate' was built under R version 3.6.2
ggplot(airquality %>%
filter(Month==5),
aes(Day, Temp)) +
labs(title='{closest_state}')+
geom_point(color='red', size=10) +
geom_text(aes(label=paste("temp:", Temp, "\n",
"day:", Day)),
x=20,
y=80,
size=10)+
transition_states(Day, state_length = 50)+
shadow_mark(colour = 'black', size = 5)

Created on 2020-03-24 by the reprex package (v0.3.0)
