I am playing around with gganimate
and I do believe it is acting slightly funky when it comes to labels (I've basically followed this example).
I am generating the following .gif with this code snippet (you can find the data here, didn't want post length to explode).
library(gganimate)
library(dplyr)
df <- read.csv("https://pastebin.com/raw/QvhdVqwM", stringsAsFactors = FALSE) %>%
mutate(date = as.Date(date))
countries_anim <- df %>%
filter(country_code == "de") %>%
ggplot(aes(date, value, colour = city_name)) +
geom_line() +
geom_segment(aes(xend = max(date) - 30, yend = value), linetype = 2,
colour = "grey") +
geom_text(aes(x = max(date) - 29, label = city_name), hjust = 0) +
theme(legend.position = "bottom") +
guides(colour = guide_legend(title.position = "top")) +
transition_reveal(date)
n_days <- as.integer(max(df$date) - min(df$date))
anim <- animate(plot = countries_anim, duration = 10,
renderer = gifski_renderer(file = 'figures/de.gif'))
Everything works pretty well except one minor annoyance: at the very beginning of the animation, some annotations (which are supposed to follow time series trend) get permanently printed in the plot area. I've tried to change renderer but the issue seems to be completely uncorrelated.
I am not that versed on gganimate
internals and I'm wondering how I could go debugging the issue.