Jul 2, 2014

Random graphs (24): Small-multiples and overlayed line plots


clear

// SG.GEN.PARL.ZS - Proportion of seats held by women in national parliaments (%)
wbopendata, indicator(SG.GEN.PARL.ZS) clear long

// Keep European countries
keep if regioncode == "ECS" // "Europe & Central Asia (all income levels)"

// Keep EU-28
keep if inlist(iso2code, "AT", "BE", "BG", "CY", "CZ", "DE", "DK", "EE", "ES") | ///
        inlist(iso2code, "FI", "FR", "GB", "GR", "HR", "HU", "IE", "IT", "LI") | ///
  inlist(iso2code, "LT", "LU", "LV", "NL", "PL", "PT", "RO", "SE", "SI") | ///
  inlist(iso2code, "SK") // EU-28

// Identify and rename salient variables
ren sg_gen_parl_zs women
label var women "% of national parliament seats held by women"
ren iso2code cntry
drop countrycode region regioncode

// Reshape to drop empty observations
reshape wide women, i(cntry) j(year)
dropmiss women1960-women2014, force
reshape long

// Calculate EU-28 mean
preserve
collapse (mean) women, by(year)
gen cntry = "{bf:EU-28}"
tempfile eu28
save `eu28', replace
restore
append using `eu28'

// Plot small-multiples figure twoway scatter women year /// , by(cntry /// , note(" ") /// caption("{it:Source:} World Development Indicators, date of extraction: 2015-05-25", span size(small))) /// cmissing(no) /// connect(l) /// msymbol(o) /// xtitle("") xlabel(1990 1997 2000 2005 2010 2014, ang(45)) /// ylabel(0 (10) 50) /// name(small_multiples, replace)
// Plot overlayed figure encode cntry, gen(country) // No strings for -xtline- xtset country year, yearly // Declare panel xtline women if cntry != "{bf:EU-28}" /// , overlay /// xlabel(1990 1997 2000 2005 2010 2014) xtitle("Year") /// plot1opts(lpattern(dash)) plot2opts(lpattern(dash)) /// plot3opts(lpattern(dash)) plot4opts(lpattern(dash)) /// plot5opts(lpattern(dash)) plot6opts(lpattern(dash)) /// plot7opts(lpattern(dash)) plot8opts(lpattern(dash)) /// plot9opts(lpattern(dash)) plot10opts(lpattern(dash)) /// plot11opts(lpattern(dash)) plot12opts(lpattern(dash)) /// plot13opts(lpattern(dash)) plot14opts(lpattern(dash)) /// plot15opts(lpattern(dash)) plot16opts(lpattern(dash)) /// plot17opts(lpattern(dash)) plot18opts(lpattern(dash)) /// plot19opts(lpattern(dash)) plot20opts(lpattern(dash)) /// plot21opts(lpattern(dash)) plot22opts(lpattern(dash)) /// plot23opts(lpattern(dash)) plot24opts(lpattern(dash)) /// plot25opts(lpattern(dash)) plot26opts(lpattern(dash)) /// plot27opts(lpattern(dash)) plot28opts(lpattern(dash)) /// name(overlay, replace) /// addplot(line women year if cntry == "{bf:EU-28}", /// lwidth(thick) lpattern(solid) sort(cntry year)) /// legend(order(29 "EU-28 (unweighted average)") pos(6) ring(0)) /// caption("{it:Source:} World Development Indicators, date of extraction: 2015-05-25", span size(small)) /// ytitle("% of national parliament seats" "held by women, EU-28 countries")