-
-
Save mbauman/934d22b808b9fdf97848e63a31c24789 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import HTTP, CSV | |
using Plots, DataFrames | |
df = CSV.read(IOBuffer(String(HTTP.get("https://covid.ourworldindata.org/data/total_cases.csv").body)), normalizenames=true) | |
function doit(df, countries, alignment) | |
plot(legend=:topleft) | |
for country in countries | |
c = df[:, Symbol(country)] | |
plot!(df.date .- df.date[findfirst(coalesce.(c,0) .>= alignment)], c, label=string(country), yaxis=:log) | |
end | |
xlabel!("Days after $alignment cases") | |
xlims!(-1, last(xlims())) | |
ylims!(alignment*.9, last(ylims())) | |
end | |
doit(df, [:Italy, :United_States, :United_Kingdom, :China], 100) | |
Absolutely. Consider it MIT licensed. import
instead of using because those packages largely rely on API style like CSV.read
anyhow and HTTP
exports a stack
that conflicts with Dataframes
(I was playing with the JHU dataset, too, which requires some munging).
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is great, thanks for sharing! Here is the plot as of 18 March 2020 for those who just want to see it
I have a few questions/comments:
import HTTP, CSV
and notusing HTTP, CSV
?alignment
cases) cannot be perfect because the data is daily. What about "force" aligning it by linearly interpolating the data to every minute first? [EDIT: Oh actually it's just that the China data starts at 278 cases...]