Skip to content

Instantly share code, notes, and snippets.

@hawleylin
Last active May 7, 2020 12:05
Show Gist options
  • Save hawleylin/60a6cadbd9d8dcbdf3348cad4a52dd32 to your computer and use it in GitHub Desktop.
Save hawleylin/60a6cadbd9d8dcbdf3348cad4a52dd32 to your computer and use it in GitHub Desktop.
library(ggplot2)
library(gganimate)
library(gifski)
g7 <- ggplot(brics, aes(gdp, medal, size = population, colour = country)) +
geom_point(show.legend = TRUE, alpha = 0.7) +
scale_size(range = c(2, 9)) +
scale_x_log10() +
theme_bw() +
labs(title = 'Year: {round(({frame_time}-1992)/4)*4+1992}', x = 'GDP', y = 'The number of gold medal') +
transition_time(year) +
shadow_wake(wake_length = 0.1, alpha = FALSE) +
ease_aes('linear')
animate(g7, duration = 5, fps = 30, width = 500, height = 500, renderer = gifski_renderer())
anim_save("brics-4.gif")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment