It is very foolish to argue with the Dutch about Dutch, but https://en.wikipedia.org/wiki/Piet_Mondrian is behind what I have been accustomed to....
-
Login or Register
- Log in with
local url = "https://raw.githubusercontent.com/TheEconomist/covid-19-excess-deaths-tracker/master/output-data/excess-deaths/"
local filemonthly = "all_monthly_excess_deaths.csv"
local fileweekly = "all_weekly_excess_deaths.csv"
local fileqtrly = "all_quarterly_excess_deaths.csv"
insheet using "`url'`filemonthly'", clear
generate monthly = 1
/* Install user written commands:
ssc install heatplot, replace
ssc install blindschemes, replace
*/
* Keeping Selected regions from each country
egen tag = tag( country region)
bysort country: egen count = total(tag)
generate ctr_reg = 1 if (country==region) & count>1
drop if count>1 & ctr_reg==.
drop country tag count ctr_reg
* Saving todays date in local
local date: di %tdM_D_CY daily("$S_DATE", "DMY")
* Generate year month indicator
encode region, gen(Region)
bysort Region: generate yrmth = _n
bysort Region: generate yrmth1 = _n-0.5
#delimit ;
label define yrmth
1 "Jan 2020" 2 "Feb"
3 "Mar" 4 "Apr"
5 "May" 6 "Jun"
7 "Jul" 8 "Aug"
9 "Sep" 10 "Oct"
11 "Nov" 12 "Dec"
13 "Jan 2021" 14 "Feb"
15 "Mar" 16 "Apr"
17 "May" 18 "Jun"
19 "Jul" 20 "Aug"
21 "Sep" 22 "Oct"
23 "Nov" 24 "Dec"
25 "Jan 2022" 26 "Feb"
, replace ;
#delimit cr
label values yrmth yrmth
* Drawing the Visual
replace excess_deaths_pct_change = round(excess_deaths_pct_change*100, 1)
quietly: summarize yrmth
local count = `r(max)' + 1
#delimit ;
heatplot excess_deaths_pct_change i.Region i.yrmth,
ytitle("")
xtitle("")
legend(subtitle("{bf}Deviation from expected deaths, % ",
span
size(1.75)
)
pos(1)
ring(1)
rows(1)
keygap(0.5)
colgap(0)
size(1.5)
symysize(0.85)
symxsize(7)
order(1 "" 2 "0" 3 "+25" 4 "+50" 5 "+100" 6 "+200")
stack
)
ylabel(,
angle(horizontal)
labgap(-145)
labsize(2)
noticks
labcolor(gs5)
nogrid
)
yscale(
noline
alt
reverse
)
xscale(extend)
xlabel(, nolabels tlength(0) nogrid
)
graphregion(margin(22=2))
plotregion(margin(b=0 t=0))
color("234 242 245" "254 239 216" "253 204 138" "252 140 89" "227 73 51" "179 0 1")
cuts(@min 0 25 50 100 200 @max)
p(
lcolor(white)
lwidth(0.1)
lalign(center)
)
addplot(
scatter Region yrmth,
color(white%0)
xaxis(1)
xtitle("", axis(1))
xlabel(
1/`count',
valuelabels
labsize(1.75)
labcolor(gs5)
nogrid
axis(1)
)
||
scatter Region yrmth,
color(white%0)
xaxis(2)
xtitle("", axis(2))
xlabel(
1/`count',
valuelabels
labsize(1.75)
labcolor(gs5)
nogrid
axis(2)
)
)
title("{bf}Excess deaths by country or city",
pos(11)
size(2.25)
margin(l=-20 b=-10 t=2)
)
subtitle("Last updated on - `c(current_date)'",
pos(11)
size(2)
margin(l=-20 b=-10 t=5)
)
scheme(plotplain);
#delimit cr
local url = "https://raw.githubusercontent.com/TheEconomist/covid-19-excess-deaths-tracker/master/output-data/excess-deaths/" local filemonthly = "all_monthly_excess_deaths.csv" local fileweekly = "all_weekly_excess_deaths.csv" local fileqtrly = "all_quarterly_excess_deaths.csv" insheet using "`url'`filemonthly'", clear generate monthly = 1 /* Install user written commands: ssc install heatplot, replace ssc install blindschemes, replace */ * Keeping Selected regions from each country egen tag = tag( country region) bysort country: egen count = total(tag) generate ctr_reg = 1 if (country==region) & count>1 drop if count>1 & ctr_reg==. drop country tag count ctr_reg * Saving todays date in local local date: di %tdM_D_CY daily("$S_DATE", "DMY") * Generate year month indicator encode region, gen(Region) bysort Region: generate yrmth = _n #delimit ; label define yrmth 1 "Jan 2020" 2 "Feb" 3 "Mar" 4 "Apr" 5 "May" 6 "Jun" 7 "Jul" 8 "Aug" 9 "Sep" 10 "Oct" 11 "Nov" 12 "Dec" 13 "Jan 2021" 14 "Feb" 15 "Mar" 16 "Apr" 17 "May" 18 "Jun" 19 "Jul" 20 "Aug" 21 "Sep" 22 "Oct" 23 "Nov" 24 "Dec" 25 "Jan 2022" 26 "Feb" , replace ; #delimit cr label values yrmth yrmth * Drawing the Visual replace excess_deaths_pct_change = round(excess_deaths_pct_change*100, 1) quietly: summarize yrmth local count = `r(max)' + 1 local xlab forval i=1/`count'{ local xlab "`xlab' `=`i'-0.5' `" "`:lab (yrmth) `i''" "'" } #delimit ; heatplot excess_deaths_pct_change i.Region i.yrmth, ytitle("") xtitle("") legend(subtitle("{bf}Deviation from expected deaths, % ", span size(1.75) ) pos(1) ring(1) rows(1) keygap(0.5) colgap(0) size(1.5) symysize(0.85) symxsize(7) order(1 "" 2 "0" 3 "+25" 4 "+50" 5 "+100" 6 "+200") stack ) ylabel(, angle(horizontal) labgap(-145) labsize(2) noticks labcolor(gs5) nogrid ) yscale( noline alt reverse ) xscale(extend) xlab(`xlab', labsize(1.75) labcolor(gs5)) graphregion(margin(22=2)) plotregion(margin(b=0 t=0)) color("234 242 245" "254 239 216" "253 204 138" "252 140 89" "227 73 51" "179 0 1") cuts(@min 0 25 50 100 200 @max) p( lcolor(white) lwidth(0.1) lalign(center) ) addplot(scatter Region yrmth, color(white%0) xaxis(2) xtitle("", axis(2)) xlabel( 1/`count', valuelabels labsize(1.75) labcolor(gs5) nogrid axis(2) ) ) title("{bf}Excess deaths by country or city", pos(11) size(2.25) margin(l=-20 b=-10 t=2) ) subtitle("Last updated on - `c(current_date)'", pos(11) size(2) margin(l=-20 b=-10 t=5) ) scheme(plotplain); #delimit cr
local xlab "`xlab' `=`i'-0.5' `" "`:lab (yrmth) `i''" "'"
xlab " 0.5 "Jan 2020" "
xlab " 0.5 "Jan 2020" 1.5 "Feb" "
heatplot c2m_workplaceclosing i.state2 i.dm, xlabel(, labsize(*0.6) angle(vertical) format(%tm) nogrid) /// color(viridis, reverse) /// cuts(0(1)4) /// legend(subtitle("{bf} Workplace Closures", span size(1.75)) /// pos(1) ring(1) rows(1) keygap(0.5) colgap(0) size(1.5) symysize(0.85) symxsize(7) /// order(0 1 "Open" 2 "rec. close" 3 "Part. Close" 4 "Fully Close" ) stack ) /// p(lcolor(black%10) lwidth(*0.15)) /// ytitle("") /// xtitle("", size(vsmall)) /// title("{bf}Workplace closure policy", pos(11) size(2.25) margin(b=-10 t=2))
summ dm local x1 = `r(min)' local x2 = `r(max)' heatplot c2m_workplaceclosing i.state2 dm, /// yscale(noline) /// ylabel(, nogrid labsize(*0.7)) /// xlabel(`x1'(1)`x2', labsize(*0.6) angle(vertical) format(%tm) nogrid) /// color(viridis, reverse) /// cuts(0(1)4) /// legend(subtitle("{bf} Workplace Closures", span size(1.75)) /// pos(1) ring(1) rows(1) keygap(0.5) colgap(0) size(1.5) symysize(0.85) symxsize(7) /// order(0 1 "Open" 2 "rec. close" 3 "Part. Close" 4 "Fully Close" ) stack ) /// p(lcolor(black%10) lwidth(*0.15)) /// ytitle("") /// xtitle("", size(vsmall)) /// title("{bf}Workplace closure policy", pos(11) size(2.25) margin(b=-10 t=2))
* Example generated by -dataex-. For more info, type help dataex clear input long state2 double(c2m_workplaceclosing dm) 5 2 722 5 0 748 5 1 730 5 2 737 5 0 753 5 0 732 5 3 736 5 0 720 5 1 742 5 1 735 5 0 734 5 0 754 5 2 726 5 2 738 5 1 744 5 2 725 5 0 752 5 0 751 5 0 747 5 1 740 5 3 724 5 0 721 5 0 743 5 3 723 5 0 750 5 0 733 5 0 749 5 1 731 5 1 729 5 0 755 5 0 745 5 0 746 5 3 727 5 1 741 5 1 739 5 3 728 18 1 734 18 1 748 18 2 727 18 1 729 18 2 732 18 1 749 18 1 753 18 2 725 18 0 720 18 0 741 18 2 745 18 3 737 18 3 722 18 1 755 18 2 728 18 1 752 18 2 726 18 3 738 18 1 733 18 1 730 18 2 739 18 3 736 18 1 750 18 0 721 18 2 744 18 1 754 18 0 743 18 1 751 18 1 731 18 0 746 18 2 740 18 0 742 18 3 723 18 1 735 18 3 724 18 0 747 22 1 722 22 0 730 22 2 725 22 2 727 22 2 742 22 3 736 22 1 743 22 1 733 22 2 728 22 3 724 22 0 752 22 2 726 22 0 749 22 0 720 22 2 740 22 1 744 22 1 729 22 3 737 22 2 741 22 0 754 22 1 734 22 0 755 22 1 732 22 2 738 22 0 747 22 3 723 22 1 745 22 0 721 end format %tm state2 format %tm dm label values state2 state2 label def state2 5 "Bihar", modify label def state2 18 "Kerala", modify label def state2 22 "Maharashtra", modify
heatplot c2m_workplaceclosing i.state2 dm, xlabel(, labsize(*0.6) angle(vertical) format(%tm) nogrid) ///
net install gr0034, from(http://www.stata-journal.com/software/sj8-2)
gen lab= string(dm, "%tm") gen dm2=dm labmask dm2, values(lab) heatplot c2m_workplaceclosing i.state2 i.dm2, xlabel(,val labsize(*0.5) angle(vertical) nogrid) /// color(viridis, reverse) /// cuts(0(1)4) /// legend(subtitle("{bf} Workplace Closures", span size(1.75)) /// pos(1) ring(1) rows(1) keygap(0.5) colgap(0) size(1.5) symysize(0.85) symxsize(7) /// order(0 1 "Open" 2 "rec. close" 3 "Part. Close" 4 "Fully Close" ) stack ) /// p(lcolor(black%10) lwidth(*0.15)) /// ytitle("") /// xtitle("", size(vsmall)) /// title("{bf}Workplace closure policy", pos(11) size(2.25) margin(b=-10 t=2))
gen lab= string(dm, "%tm") gen dm2=dm labmask dm2, values(lab) ******************************************************************************** heatplot c2m_workplaceclosing i.state2 i.dm2, /// xlabel(,val labsize(*0.5) angle(vertical) nogrid) /// color(viridis, reverse) /// cuts(0(1)4) /// legend(subtitle("{bf} Workplace Closures", span size(1.75)) /// pos(1) ring(1) rows(1) keygap(0.5) colgap(0) size(1.5) symysize(0.85) symxsize(9) /// *change symxsize to increase legendsize order(0 1 "Open" 2 "rec. close" 3 "Part. Close" 4 "Fully Close" ) stack ) /// p(lcolor(black%10) lwidth(*0.15)) /// ytitle("") /// xtitle("", size(vsmall)) /// title("{bf}Workplace closure policy", pos(11) size(2.25) margin(b=-10 t=2)) heatplot c4m_restrictionsongatherings i.state2 i.dm2, /// xlabel(,val labsize(*0.5) angle(vertical) nogrid) /// color(viridis, reverse) /// cuts(0(1)4) /// legend(subtitle("{bf} Restrict gatherings", span size(1.75)) /// pos(1) ring(1) rows(1) keygap(0.5) colgap(0) size(1.5) symysize(0.85) symxsize(9) /// order(0 1 "No res." 2 "res. >1000" 3 "res 101-1000" 4 "res 11-101" ) stack ) /// p(lcolor(black%10) lwidth(*0.15)) /// ytitle("") /// xtitle("", size(vsmall)) /// title("{bf}Restrict gatherings policy", pos(11) size(2.25) margin(b=-10 t=2))
local varlist c2m_workplaceclosing c4m_restrictionsongatherings foreach var of local varlist { local title local legend_title local xlabel_option local order if "`var'" == "c2m_workplaceclosing" { local title "Workplace closure policy" local legend_title "Workplace Closures" local xlabel_option "i.dm2" local order 0 1 "Open" 2 "rec. close" 3 "Part. Close" 4 "Fully Close" } else if "`var'" == "c4m_restrictionsongatherings" { local title "Restrict gatherings policy" local legend_title "Restrict gatherings" local xlabel_option "i.dm2" local order 0 1 "No res." 2 "res. >1000" 3 "res 101-1000" 4 "res 11-101" } heatplot `var' i.state2 `xlabel_option', /// xlabel(,val labsize(*0.5) angle(vertical) nogrid) /// color(viridis, reverse) /// cuts(0(1)4) /// legend(subtitle("{bf} `legend_title'", span size(1.75)) /// pos(1) ring(1) rows(1) keygap(0.5) colgap(0) size(1.5) symysize(0.85) symxsize(9) /// order(`order') stack) /// p(lcolor(black%10) lwidth(*0.15)) /// ytitle("") /// xtitle("", size(vsmall)) /// title("{bf}`title'", pos(11) size(2.25) margin(b=-10 t=2)) }
* Example generated by -dataex-. For more info, type help dataex clear input long state2 double(c2m_workplaceclosing c4m_restrictionsongatherings dm) float dm2 5 2 1 722 722 5 0 0 748 748 5 1 2 730 730 5 2 3 737 737 5 0 0 753 753 5 0 2 732 732 5 3 3 736 736 5 0 0 720 720 5 1 1 742 742 5 1 3 735 735 5 0 2 734 734 5 0 0 754 754 5 2 3 726 726 5 2 3 738 738 5 1 2 744 744 5 2 3 725 725 5 0 0 752 752 5 0 0 751 751 5 0 0 747 747 5 1 1 740 740 5 3 4 724 724 5 0 0 721 721 5 0 0 743 743 5 3 4 723 723 5 0 0 750 750 5 0 2 733 733 5 0 0 749 749 5 1 2 731 731 5 1 2 729 729 5 0 0 755 755 5 0 1 745 745 5 0 0 746 746 5 3 4 727 727 5 1 1 741 741 5 1 3 739 739 5 3 4 728 728 18 1 0 734 734 18 1 0 748 748 18 2 3 727 727 18 1 4 729 729 18 2 2 732 732 18 1 0 749 749 18 1 0 753 753 18 2 3 725 725 18 0 0 720 720 18 0 3 741 741 18 2 3 745 745 18 3 3 737 737 18 3 4 722 722 18 1 0 755 755 18 2 3 728 728 18 1 0 752 752 18 2 3 726 726 18 3 4 738 738 18 1 2 733 733 18 1 3 730 730 18 2 3 739 739 18 3 3 736 736 18 1 0 750 750 18 0 0 721 721 18 2 3 744 744 18 1 0 754 754 18 0 2 743 743 18 1 0 751 751 18 1 2 731 731 18 0 0 746 746 18 2 2 740 740 18 0 2 742 742 18 3 4 723 723 18 1 2 735 735 18 3 4 724 724 18 0 0 747 747 22 1 1 722 722 22 0 2 730 730 22 2 3 725 725 22 2 3 727 727 22 2 3 742 742 22 3 4 736 736 22 1 3 743 743 22 1 2 733 733 22 2 3 728 728 22 3 3 724 724 22 0 0 752 752 22 2 3 726 726 22 0 0 749 749 22 0 0 720 720 22 2 3 740 740 22 1 4 744 744 22 1 3 729 729 22 3 4 737 737 22 2 3 741 741 22 0 0 754 754 22 1 2 734 734 22 0 0 755 755 22 1 2 732 732 22 2 3 738 738 22 0 0 747 747 22 3 4 723 723 22 1 0 745 745 22 0 0 721 721 end format %tm state2 format %tm dm label values state2 state2 label def state2 5 "Bihar", modify label def state2 18 "Kerala", modify label def state2 22 "Maharashtra", modify label values dm2 dm2 label def dm2 720 "2020m1", modify label def dm2 721 "2020m2", modify label def dm2 722 "2020m3", modify label def dm2 723 "2020m4", modify label def dm2 724 "2020m5", modify label def dm2 725 "2020m6", modify label def dm2 726 "2020m7", modify label def dm2 727 "2020m8", modify label def dm2 728 "2020m9", modify label def dm2 729 "2020m10", modify label def dm2 730 "2020m11", modify label def dm2 731 "2020m12", modify label def dm2 732 "2021m1", modify label def dm2 733 "2021m2", modify label def dm2 734 "2021m3", modify label def dm2 735 "2021m4", modify label def dm2 736 "2021m5", modify label def dm2 737 "2021m6", modify label def dm2 738 "2021m7", modify label def dm2 739 "2021m8", modify label def dm2 740 "2021m9", modify label def dm2 741 "2021m10", modify label def dm2 742 "2021m11", modify label def dm2 743 "2021m12", modify label def dm2 744 "2022m1", modify label def dm2 745 "2022m2", modify label def dm2 746 "2022m3", modify label def dm2 747 "2022m4", modify label def dm2 748 "2022m5", modify label def dm2 749 "2022m6", modify label def dm2 750 "2022m7", modify label def dm2 751 "2022m8", modify label def dm2 752 "2022m9", modify label def dm2 753 "2022m10", modify label def dm2 754 "2022m11", modify label def dm2 755 "2022m12", modify
if "`var'" == "c2m_workplaceclosing" { local title "Workplace closure policy" local legend_title "Workplace Closures" local xlabel_option "i.dm2" local order 0 1 "Open" 2 "rec. close" 3 "Part. Close" 4 "Fully Close" } if "`var'" == "c4m_restrictionsongatherings" {
Comment