Created
May 17, 2022 14:11
-
-
Save xpqz/c4f13f8ee97f47103c7f1a481481d3e1 to your computer and use it in GitHub Desktop.
Modifed version of Nic's OWID plot
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
{sp}←OwidCovidData;Causeway;InitCauseway;View;countries_to_plot;csv;data;date;dates;field;fields_to_plot;location;locations;miss;row;sp;values | |
miss ← ¯1E300 ⍝ missing value | |
csv ← {⎕CSV ⍵ ⍬ 4} 'covid_subset2.csv' | |
dates ← {⍵[⍋⍵]}∪date ← 20 1⎕DT csv[;2] | |
csv[;2] ← date | |
locations ← ∪location←csv[;1] | |
row ← csv[;1 2]⍳↑locations∘.{⍺ ⍵}dates ⍝ row for each [location;date] | |
csv ⍪← (⊂'')(⊂'')miss miss | |
data ← csv[row;3 4] ⍝ data[location;date;fields] | |
fields_to_plot ← 'New cases per million' 'New deaths per million' | |
countries_to_plot ← 'United States' 'Canada' 'United Kingdom' 'France' 'Denmark' | |
'InitCauseway' 'View'⎕CY'sharpplot' | |
InitCauseway ⍬ | |
sp ← ⎕NEW Causeway.SharpPlot | |
sp.MissingValue ← miss | |
sp.SetTrellis ≢fields_to_plot | |
:For field :In ⍳≢fields_to_plot | |
sp.NewCell ⍝ move to next cell | |
sp.Heading ← field⊃fields_to_plot | |
sp.MarginBottom ← 70 ⍝ need more margin thand default for key | |
sp.SetKeyText ⊂countries_to_plot | |
sp.YAxisStyle ← Causeway.YAxisStyles.LogScale | |
sp.XAxisStyle ← Causeway.XAxisStyles.(Date+MonthlyTicks) | |
sp.XDateFormat ← 'MMM-yy' | |
values ← ↓data[;;field] | |
sp.DrawLineGraph values dates | |
sp.DrawKey ⍬ | |
:EndFor | |
View sp |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Dataset available here: https://github.com/xpqz/owidp