Showing posts with label tabplot. Show all posts
Showing posts with label tabplot. Show all posts

Mar 22, 2018

Random graphs (128): Comparing distributions

// Open cumulated Allbus 1980-2014
use ost_west v152 year using ZA4584_v1-0-0.dta, clear

// West Germany only
keep if ost_west == 1

// Subjective SES
recode v152 (0 = .) (97 98 99 = .), gen(topbot)
label var topbot "Subjective SES"

// Drop years with missing data
drop if inlist(year, 1984, 1994, 1996, 1998)
// Drop early years
drop if year < 1998
label drop year // Drop label

// Generate average subjective SES per year
bysort year: egen avg = mean(topbot)

// Figure
tabplot topbot year, yasis xasis horizontal percent barw(1) bfcolor(none) //
                     xtitle("") subtitle("") note("") //
                     addplot(connect avg year, sort msymbol(O) mcolor(black) msize(large)) 

Feb 19, 2018

Random graphs (126): Turning tables into figures

sdmxuse data ESTAT, dataset(lfsa_epgar) start(2010) end(2010) clear

keep if inlist(geo, "AT", "BE", "BG", "CY", "CZ", "DK", "EE", "FI") ///
      | inlist(geo, "FR", "DE", "EL", "HU", "IE", "LT", "NL", "NO") ///
      | inlist(geo, "PL", "PT", "ES", "SE", "CH", "UK") 
keep if age == "Y_GE15"

replace geo = "GR" if geo == "EL"
kountry geo, from(iso2c)
rename NAMES_STD country

drop if sex == "T"
replace sex = "Men" if sex == "M"
replace sex = "Women" if sex == "F"
encode reason, gen(reasonno)
label var reasonno "Reasons for part-time work"

label define reasonno 1 "Care activities" ///
                      2 "Other personal reasons" ///
                      3 "Own illness, disability" 4 "Education, training" ///
                      5 "Could not find full-time job" 6 "Other", modify

replace value = value * 10
expand value
drop if missing(value)

tabplot reasonno country, by(sex, ///
                          note("{it:Note:} Bars and numbers indicate percentage of part-time workers per country" ///
                               "{it:Source:} Eurostat, lfsa_egpar, data refer to 2010.")) ///
                          percent(sex country) ///
                          showval(mlabsize(tiny) format(%6.0f)) xtitle("") ///
                          xlabel(, angle(vertical) labsize(small)) name(figure2, replace)

May 24, 2017

Random graphs (95): Categorical variables

use "ZA4582_v1-0-0.dta", clear

recode v151 (9 = .a "No response") ///
            (8 = .b "Don't know") ///
            (7 = .c "Refused") ///
            (6 = .d "None of the strata") ///
            (5 =  1 "Upper class") ///
            (4 =  2 "Upper middle class") ///
            (3 =  3 "Middle class") ///
            (2 =  4 "Working class") ///
            (1 =  5 "Lower class") ///
           , gen(subjclass)
label var subjclass "Subjective social class"

generate nolabelyear = year     
label define ost_west 1 "Western Germany" 2 "Eastern Germany", modify
graph bar (count), over(subjclass, descending) /// over(nolabelyear, label(angle(vertical))) /// by(ost_west, note("{it:Source:} German General Social Survey (Allbus), doi: 10.4232/1.12439.", span) col(1)) /// percent stack asyvars ytitle(%) ysize(8) /// legend(rows(3) colfirst) name(figure1, replace)
tabplot subjclass nolabelyear, by(ost_west, /// note("{it:Source:} German General Social Survey (Allbus), doi: 10.4232/1.12439.", span)) /// percent(ost_west nolabelyear) /// showval(mlabsize(tiny)) xtitle("") /// xlabel(, angle(vertical)) name(figure2, replace)