use 7363_F1.dta, clear
// Prepare wave variable
label define wavex 1 "1991" 2 "1995" 3 "2000" 4 "2005" 5 "2010"
label val wave wavex
// Using the internet
fre y10_q_16
tab y10_q_16 wave
keep if wave > 3 // Drop waves where variable is missing
// Create variable of interest
generate nointernetuse = .
replace nointernetuse = (y10_q_16 == 7) if !missing(y10_q_16)
// Collapse data
collapse (mean) nointernetuse, by(countid wave)
replace nointernetuse = nointernetuse * 100
reshape wide nointernetuse, i(countid) j(wave)
// Sort variable labels
egen order_ = rank(-nointernetuse5), unique
labmask order_, val(countid) decode
label define order_ 8 "Macedonia", modify
twoway (pcarrow nointernetuse4 order_ nointernetuse5 order_, horizontal) ///
(scatter order_ nointernetuse5 if missing(nointernetuse4)) ///
, ylabel(1/34, val) legend(order(1 "Decrease 2005 to 2010" ///
2 "No data for 2005") pos(7) ring(0) size(*.8)) ///
ytitle("") ysize(8) xscale(alt) xtitle("% of labor force" ///
"never using internet/email" ///
"for professional reasons") ///
xlabel(10 (10) 80, grid) ///
note(" " "{it:Source:} European Working Conditions Survey 2005 and 2010", span)
Showing posts with label twoway pcarrow. Show all posts
Showing posts with label twoway pcarrow. Show all posts
Apr 25, 2016
Random graphs (74): Arrow plot
Mar 26, 2013
Random graphs (11): Visualizing multiple group differences
// Prepare data // Formal care use by income quintiles, households with a child input str5 geo inc1 inc3 inc5 AT 10 7 9 BE 17 38 57 BG 0 10 15 CH 9 27 53 CY 16 19 30 CZ 3 3 4 DE 21 22 23 DK 87 72 83 EE 16 22 14 EL 6 11 12 ES 29 30 45 FI 18 27 41 FR 15 60 64 HR 6 8 13 HU 7 14 15 IE 8 12 34 IS 37 44 34 IT 17 26 28 LT 2 16 10 LU 23 34 56 LV 7 24 11 MT 0 16 15 NL 27 55 70 NO 34 57 53 PL 0 2 4 PT 14 44 36 RO 5 5 13 SE 44 56 32 SI 41 39 38 SK 2 5 0 UK 20 50 53 EU-27 17 34 36 end // Encode country variable encode geo, gen(country) // Create country variable sortet by the size of the income gap gen diff = inc5 - inc1 // Income gap egen order = rank(-diff), unique // Create rank variable labmask order, value(country) decode // Assign value // labels of country to variable order based on its values
// Run-of-the-mill dot plot
twoway dot inc1 inc3 inc5 order, vertical ///
legend(label(1 "1{sup:st} income quintile (poorest)") ///
label(2 "3{sup:rd} income quintile") ///
label(3 "5{sup:th} income quintile (richest)") ///
order(3 2 1) ring(0) pos(12)) ///
msymbol(th oh t) ///
xlabel(1/32, valuelabels ang(v)) /// // turn on labels
xtitle("") ///
ytitle("% formal care use of households with" ///
"a child younger than 3 years of age") ///
caption("Note: Countries sorted by the size of the difference */
/* between the 5{sup:th} and 1{sup:st} quintile" ///
"Source: EU-SILC 2010", span) ///
name(incomegap1, replace)
// Without dots
scatter inc1 inc3 inc5 order, ///
legend(label(1 "1{sup:st} income quintile (poorest)") ///
label(2 "3{sup:rd} income quintile") ///
label(3 "5{sup:th} income quintile (richest)") ///
order(3 2 1) ring(0) pos(12)) ///
msymbol(th oh t) ///
xlabel(1/32, valuelabels ang(v)) /// // turn on labels
xtitle("") ///
ytitle("% formal care use of households with" ///
"a child younger than 3 years of age") ///
caption("Note: Countries sorted by the size of the difference /*
*/between the 5{sup:th} and 1{sup:st} quintile" ///
"Source: EU-SILC 2010", span) ///
name(incomegap2, replace)
// With numbers instead of symbols
// Not sure whether this is the most elegant move
reshape long inc, i(geo) j(j)
twoway (dot inc order if j == 1, mlabel(j) mlabpos(0) msymbol(i)) ///
(dot inc order if j == 3, mlabel(j) mlabpos(0) msymbol(i)) ///
(dot inc order if j == 5, mlabel(j) mlabpos(0) msymbol(i)), ///
legend(label(1 "1 1{sup:st} income quintile (poorest)") ///
label(2 "3 3{sup:rd} income quintile") ///
label(3 "5 5{sup:th} income quintile (richest)") ///
order(3 2 1) ring(0) pos(12)) ///
xlabel(1/32, valuelabels ang(v)) /// // turn on labels
xtitle("") ///
ytitle("% formal care use of households with" ///
"a child younger than 3 years of age") ///
caption("Note: Countries sorted by the size of the difference /*
*/ between the 5{sup:th} and 1{sup:st} quintile" ///
"Source: EU-SILC 2010", span) ///
name(incomegap3, replace)
// With ordinal numbers and without dots
label define j 1 "1{sup:st}" 3 "3{sup:rd}" 5 "5{sup:th}"
label value j j
twoway (dot inc order if j == 1, mlabel(j) mlabpos(0) msymbol(i) ndots(0)) ///
(dot inc order if j == 3, mlabel(j) mlabpos(0) msymbol(i) ndots(0)) ///
(dot inc order if j == 5, mlabel(j) mlabpos(0) msymbol(i) ndots(0)), ///
legend(label(1 "1{sup:st} income quintile (poorest)") ///
label(2 "3{sup:rd} income quintile") ///
label(3 "5{sup:th} income quintile (richest)") ///
order(3 2 1) ring(0) pos(12)) ///
xlabel(1/32, valuelabels ang(v)) /// // turn on labels
xtitle("") ///
ytitle("% formal care use of households with" ///
"a child younger than 3 years of age") ///
caption("Note: Countries sorted by the size of the difference /*
*/ between the 5{sup:th} and 1{sup:st} quintile" ///
"Source: EU-SILC 2010", span) ///
name(incomegap4, replace)
// With arrows
reshape wide // Get data back into old format
twoway (pcarrow inc5 order inc1 order) ///
(scatter inc5 order) ///
, legend(label(2 "5{sup:th} income quintile (richest)") ///
label(1 "Difference between the 5{sup:th} /*
*/ and 1{sup:st} income quintile") ///
order(1 2) ring(0) pos(12)) ///
xlabel(1/32, valuelabels ang(v)) /// // turn on labels
xtitle("") ///
ytitle("% formal care use of households with" ///
"a child younger than 3 years of age") ///
caption("Note: Countries sorted by the size of the /*
*/ difference between the 5{sup:th} and 1{sup:st} quintile" ///
"Source: EU-SILC 2010", span) ///
name(incomegap5, replace)
// With a line
twoway (rspike inc5 inc1 order) ///
(scatter inc5 order) ///
(scatter inc1 order, msymbol(oh)) ///
(scatter inc3 order, msymbol(th)) ///
, legend(label(3 "1{sup:st} income quintile (poorest)") ///
label(2 "5{sup:th} income quintile (richest)") ///
label(1 "Difference between the 5{sup:th} /*
*/ and 1{sup:st} income quintile") ///
label(4 "3{sup:rd} income quintile") ///
order(2 4 3) ring(0) pos(12)) ///
xlabel(1/32, valuelabels ang(v)) /// // turn on labels
xtitle("") ///
ytitle("% formal care use of households with" ///
"a child younger than 3 years of age") ///
caption("Note: Countries sorted by the size of the difference /*
*/ between the 5{sup:th} and 1{sup:st} quintile" ///
"Source: EU-SILC 2010", span) ///
name(incomegap6, replace)
Labels:
Eurostat data,
labmask,
Random graphs,
scatter,
twoway dot,
twoway pcarrow,
twoway rspike
Subscribe to:
Posts (Atom)






