📈 Plot Covid-19 Confirmed Cases using Julia


In this notebook, we use Plots.jl and Pluto.jl to visualise the Covid-19 confirmed cases across the world.

The notebook below shows you how to generate the animated plot.

Note: This is the HTML rendered output of the notebook so it looses all the interactivity. You may want to directly load the pluto notebook in Julia.

GitHub Repository⚡ Pluto.jl ⚡

Covid-19 Confirmed Cases

9.8 μs
185 ms

Data

Download the data from Johns Hopkins University Center for Systems Science and Engineering

9.2 μs
"covid_data.csv"
130 ms

Load data into dataframe

6.2 μs

266 rows × 252 columns (omitted printing of 246 columns)

Province/StateCountry/RegionLatLong1/22/201/23/20
String?StringFloat64Float64Int64Int64
1missingAfghanistan33.939167.7100
2missingAlbania41.153320.168300
3missingAlgeria28.03391.659600
4missingAndorra42.50631.521800
5missingAngola-11.202717.873900
6missingAntigua and Barbuda17.0608-61.796400
7missingArgentina-38.4161-63.616700
8missingArmenia40.069145.038200
9Australian Capital TerritoryAustralia-35.4735149.01200
10New South WalesAustralia-33.8688151.20900
11Northern TerritoryAustralia-12.4634130.84600
12QueenslandAustralia-27.4698153.02500
13South AustraliaAustralia-34.9285138.60100
14TasmaniaAustralia-42.8821147.32700
15VictoriaAustralia-37.8136144.96300
16Western AustraliaAustralia-31.9505115.86100
17missingAustria47.516214.550100
18missingAzerbaijan40.143147.576900
5.2 ms

Rename the columns

6.3 μs

6 rows × 252 columns (omitted printing of 244 columns)

provincecountrylatitudelongitude1/22/201/23/201/24/201/25/20
String?StringFloat64Float64Int64Int64Int64Int64
1missingAfghanistan33.939167.710000
2missingAlbania41.153320.16830000
3missingAlgeria28.03391.65960000
4missingAndorra42.50631.52180000
5missingAngola-11.202717.87390000
6missingAntigua and Barbuda17.0608-61.79640000
295 μs

Extract the list of unique countries

7.5 μs
all_countries
10.3 μs
countries
66.9 μs
8.1 μs
549 ns
332 ns
386 ns

11 rows × 252 columns (omitted printing of 245 columns)

provincecountrylatitudelongitude1/22/201/23/201/24/20
String?StringFloat64Float64Int64Int64Int64
1AnguillaUnited Kingdom18.2206-63.0686000
2BermudaUnited Kingdom32.3078-64.7505000
3British Virgin IslandsUnited Kingdom18.4207-64.64000
4Cayman IslandsUnited Kingdom19.3133-81.2546000
5Channel IslandsUnited Kingdom49.3723-2.3644000
6Falkland Islands (Malvinas)United Kingdom-51.7963-59.5236000
7GibraltarUnited Kingdom36.1408-5.3536000
8Isle of ManUnited Kingdom54.2361-4.5481000
9MontserratUnited Kingdom16.7425-62.1874000
10Turks and Caicos IslandsUnited Kingdom21.694-71.7979000
11missingUnited Kingdom55.3781-3.436000
173 ms
US_row
243
15.2 μs

DataFrameRow (252 columns)

provincecountrylatitudelongitude1/22/201/23/201/24/201/25/201/26/201/27/20
String?StringFloat64Float64Int64Int64Int64Int64Int64Int64
243missingUS40.0-100.0112255
5.9 μs

Plots

4.4 μs

We can now start to plot the data for each country

7.6 μs
60.8 μs
current_country_idx
1
15.8 ms
1.5 ms
column_names
61.2 μs

Daily Cumulative Cases

Next, we generate the timer based plot for selected countries

10.2 μs
218 μs

6 rows × 252 columns (omitted printing of 242 columns)

provincecountrylatitudelongitude1/22/201/23/201/24/201/25/201/26/201/27/20
String?StringFloat64Float64Int64Int64Int64Int64Int64Int64
1BrazilBrazil-14.235-51.9253000000
2IndiaIndia20.593778.9629000000
3ItalyItaly41.871912.5674000000
4MexicoMexico23.6345-102.553000000
5SpainSpain40.4637-3.74922000000
6USUS40.0-100.0112255
139 ms

Add the Clock to animate the plot

8.6 μs
speed:
58.4 μs

Date: 2020-02-12

data source: Johns Hopkins CSSE

13.7 μs
plot_country (generic function with 1 method)
34.5 μs
certain_countries_plot
55.5 ms

And, that's it folks

7.7 μs

See also