Skip to content

Instantly share code, notes, and snippets.

@vikjam
Last active March 3, 2016 16:29
Show Gist options
  • Save vikjam/d4c8f22703d208304e18 to your computer and use it in GitHub Desktop.
Save vikjam/d4c8f22703d208304e18 to your computer and use it in GitHub Desktop.
Plotting histogram with line graph
webuse nlswork, clear
gen count_ln_wage = !missing(ln_wage)
collapse (sum) count_ln_wage (mean) ln_wage, by(grade year)
label var count_ln_wage "Number of individuals"
label var ln_wage "Average log(wage)"
levelsof year, local(years)
foreach yr of local years {
graph twoway (bar count_ln_wage grade, yaxis(2)) (line ln_wage grade, yaxis(1) connect(stairstep)) if year == `yr', title("`yr'")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment