Using the bar-chart-race Package
The day I posted mine on twitter I saw that Ted Petrou had released a new package, bar-chart-race, to make it easy to do the same thing. So I gave it a try using that.
This resulted in the video below, based on the code in this notebook. This creates a nice animation with smooth transitions when countries change places, with significantly less effort on the part of the user.
This is undoubtedly a more polished end product, but I found the process of creating my own bar chart race (of sorts, there is some argument about the criteria that must be met to merit the title) extremely useful in giving practice creating a function which produces a chart based on data, then looping over it to create each frame of the animation. I really enjoyed this project, and hope you have fun playing with the code too.