Oct 2, 2014

Random graphs (31): Stacked bar graph

// Read in data
input str50 mainfield men women
"Engineering and manufacturing" 0.8114392 0.1885608
"Agriculture and veterinary" 0.6366048 0.3633952
"Science, math, and computing" 0.5956416 0.4043584
"Unknown" 0.4658494 0.5341506
"General" 0.4364162 0.5635838
"Service" 0.4277022 0.5722978
"Arts and humanities" 0.3742812 0.6257188
"Social, business, and law" 0.3351495 0.6648505
"Education" 0.2417112 0.7582888
"Health and welfare" 0.1602837 0.8397163
end

// Convert to percentage
replace women = women * 100
replace men = men * 100

// 
graph hbar men women, over(mainfield, sort(women)) ///
                      legend(order(1 "Men" 2 "Women") pos(6) row(1)) ///
                      stack ///
                      ytitle("%") yalternate