I have made an animated plot using ggplot and gganimate. When setting the transition to Year the frames increment by a fraction (think like 2 months) of each year until they get to the next Year with values.
As the years with values are not a linear constant increase (ie 2000, 2001, 2002) and instead (2000, 2005, 2010 etc) there is part of the animation that just has an empty plot.
How would I set the transition or some other parameter so the only frames that show up are ones with values?
Plot code is this, from what I have read the {frame_time} part maybe is the issue? or else I believe I am missing a parameter.
homicide_gdp_df %>%
ggplot(aes(x = `Intentional_homicide_rates_per_100,000`, y = GDP_per_capita_USD, color = Country)) +
geom_point() +
labs(
title = "GDP vs Homicide Rate",
subtitle = "Year: {frame_time}",
x = "Homicide rates per log(100,000)",
y = "GDP per Capita (USD)"
) +
scale_x_log10() +
transition_time(Year)
Thank you.