Here is a minimal working example:
Code:
use "https://www.dropbox.com/s/obmd1nqc4vvdd0l/example.dta?dl=1", clear label define placementl 10 "Bottom 10%" 9 "2nd decile" 8 "3rd decile" 7 "4th decile" 6 "6th decile" 5 "5th decile" 4 "4th decile" 3 "3rd decile" 2 "2nd decile" 1 "Top 10%" label val placement placementl catplot placement, /// title("Decision Making Ability, Relative to Others", color(black)) /// percent /// blabel(bar, position(outside) size(medsmall) format(%9.1f)) /// bar(1, bcolor(orange) blcolor(none)) /// graphregion(color(white)) /// ylabel(0(5)30, nogrid) /// ytitle("")
The graph is missing the 7th, 8th, 9th, and 10th decile because there is no data to plot for these categories, but I would still like to have them as part of the graph.
Alternatively, I can get close with tabplot but haven't been able to figure out how to get the value labels to display outside of each bar (as in the graph above using catplot). Here is some code and the graph it produces:
Code:
use "https://www.dropbox.com/s/obmd1nqc4vvdd0l/example.dta?dl=1", clear gen placement2 = 11 - placement tabplot placement2, /// horizontal /// yasis /// percent /// bcolor(orange) blcolor(none) /// graphregion(color(white)) /// ytitle("") /// title("Decision making ability", color(black)) /// note("") /// subtitle("") /// xsize(4) ysize(6) /// ylabel(1 "Bottom 10%" 2 "2nd decile" 3 "3rd decile" 4 "4th decile" 5 "6th decile" 6 "5th decile" 7 "4th decile" 8 "3rd decile" 9 "2nd decile" 10 "Top 10%")
The graph gets me there, other than I'd like to add values just outside of each bar (my understanding is that with tabplot I can only post them "underneath" each bar, rather than "on top" of each bar).
Would be grateful for any suggestions or tips, using either catplot or tabplot (or even hbar).
0 Response to catplot with "empty" categories
Post a Comment