I have some time series data recorded in hours. In one of the sets (hour 5 of 10), the values are much higher than the rest of the sets. This affects the color legend for all frames of my gganimate
plot. How can I make the color legend return for the other sets with 'normal' values?
Minimal reprex using the gapminder dataset:
Original:
library(gganimate)
library(gapminder)
ggplot(gapminder, aes(gdpPercap, lifeExp, size = pop, colour = lifeExp)) +
geom_point(alpha = 0.7, show.legend = FALSE) +
scale_size(range = c(2, 12)) +
scale_x_log10() +
facet_wrap(~continent) +
# Here comes the gganimate specific bits
labs(title = 'Year: {frame_time}', x = 'GDP per capita', y = 'life expectancy') +
transition_time(year) +
ease_aes('linear')
What happens if one life expecancy in 1 year is channged to 1000?
All frames are affected
gapminder2 <- gapminder
gapminder2[1,c("lifeExp")] <- 1000
ggplot(gapminder2, aes(gdpPercap, lifeExp, size = pop, colour = lifeExp)) +
geom_point(alpha = 0.7, show.legend = FALSE) +
scale_size(range = c(2, 12)) +
scale_x_log10() +
facet_wrap(~continent) +
# Here comes the gganimate specific bits
labs(title = 'Year: {frame_time}', x = 'GDP per capita', y = 'life expectancy') +
transition_time(year) +
ease_aes('linear')