Create Bubble Maps to Track the Coronavirus

The Coronavirus virus has upended our daily lives, spreading exponentially in recent days, especially in places like New York and Italy, and showing no signs of abating.

There have been excellent visuals that capture the spread of the Coronavirus, and I want to show you how to create some of them with Python. Python has quite a few options when it comes to creating graphs, one option being plotly, an outstanding package that provides powerful visuals. This article will focus on using plotly to create bubble maps that show spread of the Coronavirus across the United States.

To get started, import the following modules:

Image for post

Next download my covid-19 dataset, which I originally downloaded from Kaggle (I cleaned the data a bit, since the format of the states in Province_State column were inconsistent):

Image for post

Next, we are going to create a widget that allows to you to pick a date, subsequently generating a bubble graph that shows the count of confirmed cases across the US:

Image for post

After we’ve created our Date Picker, we filter our dataset based on a date that is chosen:

Image for post

Now we’ll create our graph. I created comments to describe what the code does:

Image for post

Once you’ve run this block of code, a date picker along with a bubble graph of Coronavirus cases in the US on January 27th will be displayed:

Image for post

There were only a handful cases on that day, but if you were to choose a more recent day, March 20th, for example, then the map will change dramatically:

Image for post

I find this to be a very informative and powerful way to capture the spread of the virus — it’s personally my favorite. However, I’ll quickly demonstrate how to create an alternative graph to track the spread of the virus in the US:

Image for post
Image for post

Like before, not too much is going on January 27th, but if we fast-forward to the March 20th, we’ll see a remarkable change:

Image for post

In summary, these are two examples of how you can use Python to convey information in both a powerful and direct way, allowing the audience to easily grasp the gravity of the situation we currently find ourselves in. Be well. Be safe!

Stumbled into a data-centric role several years ago and have not looked back! Passionate about leveraging technology to uncover answers and improve the world.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store