I am plotting range bars, where each range bar represents a period spent in bed, starting from bedtime, ending at get-up time. I also plot three additional ranges: the time it takes to fall asleep (SOL), the amount of time wake between sleep onset and final awakenings (WASO), and the amount of time from final awakening to get-up time. So far so good!
Array
Now I want to add labels inside the three additional range bars, with the value of the label being the width of the bar (which in my graph is time). I can find no option in doing so. The blabel options are only available for graph bar and graph hbar.
My question is whether there is an option to add value labels in the three additional range bars, or if there is a way around it?
Example data is as follows:
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input float(day bedtimeh outbedtimeh_corrected sol_end wasfh_start waso_start waso_end) 1.9149957e+12 23.25 32 24 31.25 27.416666 27.833334 1.9152486e+12 22.5 29.833334 24.5 29.5 26.75 27.25 1.915344e+12 25.25 34.25 25.75 32 28.5 29.25 1.9154322e+12 23 33 24.166666 32.5 27.83333 28.83333 1.915509e+12 22.75 29.866667 23.75 29.833334 26.375 27.208334 1.9155978e+12 22.833334 32.75 23.16667 30.5 25.16667 28.5 end format %tcDay_dd-Mon day
Code:
summarize day twoway (rbar bedtimeh outbedtimeh_corrected day, lwidth(thick) fcolor(black) lcolor(black) horizontal) (rbar bedtimeh sol_end day, lwidth(thick) fcolor(gs16) lcolor(gs10) horizontal) (rbar wasfh_start outbedtimeh_corrected day, lwidth(thick) fcolor(gs16) lcolor(gs10) horizontal) (rbar waso_start waso_end day, lwidth(thick) fcolor(gs16) lcolor(gs10) horizontal), legend(off) xtitle("Tijd (24 uur)") ytitle("") xline(24, lwidth(thin) lcolor(black)) yscale(reverse) ylabel(`r(min)'(86400000)`r(max)', angle(horizontal) ticks nogrid) xlabel(20 "20" 21 "21" 22 "22" 23 "23" 24 "0" 25 "01" 26 "02" 27 "03" 28 "04" 29 "05" 30 "06" 31 "07" 32 "08" 33 "09" 34 "10" 35 "11")
FYI: the vertical blue lines are the average bedtime and get-up times, which I removed from the example code.
0 Response to Bar labels for rbar
Post a Comment