Skip to content

Instantly share code, notes, and snippets.

@mbauman
Created March 17, 2020 18:16
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save mbauman/934d22b808b9fdf97848e63a31c24789 to your computer and use it in GitHub Desktop.
Save mbauman/934d22b808b9fdf97848e63a31c24789 to your computer and use it in GitHub Desktop.
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)
@mbauman
Copy link
Author

mbauman commented Mar 18, 2020

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