An Introduction to the {gganimate} Package

Author

Dr. Joscelin Rocha-Hidalgo

Published

April 17, 2025

Buy me a coffeeBuy me a coffee


By David Keyes

This tutorial introduces the {gganimate} package, which enables the creation of animated plots in R. Using data from the UNHCR’s {refugees} package, it demonstrates how to animate a line chart showing the percentage of refugees in Syria over time. The tutorial also covers creating an animated map of refugee populations in Western Asia, utilizing geospatial data and the {sf} package. Key functions highlighted include transition_reveal() for line animations and transition_manual() for map animations.

  1. Link to tutorial: https://rfortherestofus.com/2024/11/gganimate-intro

Line chart showing the percentage of Syria’s population classified as refugees from 2000 to 2022. From 2000 to around 2011, the percentage remains near 0%. Starting in 2012, there is a steep increase, peaking at over 30% around 2017–2018, followed by a gradual decline. The title reads: “The refugee population in Syria increased dramatically as a result of its civil war.”

Back to top