Thomas Lin Pedersen edited this page Sep 4, 2018 · 2 revisions

submitted by thomasp85

One of the most impactful dataviz animations was made by Hans Rosling (video), in where he shows the development in life expectancy and a countries GDP per capita through roughly the last half of the 20th century.

The impact of the animation does not come from any complexity, but from the story it tells and how well Hans Rosling uses it to communicate the implications of it. This underscores that the goal of animations are not (only) to wow the audience, but to support communication and learning.

The Code


ggplot(gapminder, aes(gdpPercap, lifeExp, size = pop, colour = country)) +
  geom_point(alpha = 0.7) +
  scale_colour_manual(values = country_colors) +
  scale_size(range = c(2, 12)) +
  scale_x_log10() +
  facet_wrap(~continent) +
  theme(legend.position = 'none') +
  labs(title = 'Year: {frame_time}', x = 'GDP per capita', y = 'life expectancy') +


In this example we depart from the original by introducing faceting in order to more clearly separate the different continents and allow for a better assessment of how the develop as a whole. The animation part is pretty simple - we use transition_time() as the animation flows along a continuous time scale. Further we set easing to be linear with ease_aes() to avoid putting emphasis on specific time points. In order to identify the time scale of the animation we use the frame_time frame variable in the plot title to update the title to match the current year.

You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.