Animations arewonderful to attract attention to the information you want to display; they can make plots funnier, replace facets, and are very good matches to social media publications. Package gganimate
makes it very simple to animate your ggplot
. It takes you only to set a variable as frame
aesthetic and then input your ggplot
into gganimate()
function create an animated version.
Animations created this way are very gif-like; in matter of fact, you can save you plot as .gif
file. This recipe's goal is to show the general way plots made with ggplot2
can be animated using gganimate
. All this will be done under the Titanic
data set framework. Let's create an animation that shows how many women and men survived across different classes. Requirements are very important here, get them from the next section.
First, make sure that ImageMagick (https://www.imagemagick.org) is downloaded in your system. For Mac users, Homebrew is recommended ...