Creating a Bar Chart Race Animation in Python with Matplotlib

Ted Petrou
Dunder Data
Published in
10 min readMay 4, 2020

--

In this tutorial, you’ll learn how to create a bar chart race animation such as the one below using the matplotlib data visualization library in python. This post is rendered in the style of a Jupyter Notebook on the Dunder Data blog.

bar chart race

bar_chart_race python package

Along with this tutorial is the release of the python package bar_chart_race that automates the process of making these animations. This post explains the procedure from scratch.

What is a bar chart race?

A bar chart race is an animated sequence of bars that show data values at different moments in time. The bars re-position themselves at each time period so that they remain in order (either ascending or descending).

Transition bars smoothly between time periods

The trick to making a bar chart race is to transition the bars slowly to their new position when their order changes, allowing you to easily track the movements.

COVID-19 deaths data

For this bar chart race, we’ll use a small dataset produced by John Hopkins University containing the total deaths by date for six countries during the currently ongoing coronavirus…

--

--

Ted Petrou
Dunder Data

Author of Master Data Analysis with Python and Founder of Dunder Data