Basically - I want to display percentile xlines for the exposure (intensity distribution over a day), but I want these percentile lines to be labelled correctly from the top and leave the exposure on the bottom x-axis. I can achieve this somewhat by switching from xaxis(1 2) to xaxis(1 2) - but the latter then doesn't seem to then align the labels and lines/markers properly? Wondered if anyone had any suggestions on this.
Code below and output as examples for context.
OPTION 1 - passable but would rather the percentile labels on top axis and exposure on bottom
Code:
graph twoway rarea lowerM0 upperM0 $exposure, color(gs2%30) ///
|| line hrM0 hrM1 hrM2 hrM2_CC hrM2_PD $exposure, lpattern(solid) lcolor(black) lwidth(medthick) ///
legend(order(2 "M0 (95%CI)" 3 "M1" 4 "M2" 5 "M2_CC" 6 "M2_PD") ///
ring(0) bmargin(small) position(7) bmargin(large) size(small) symxsize(6.5) keygap(1.0) col(1))
ytitle("HR relative to $ref_cat") xlabel(-3.3 (0.3) -1.2) ///
yscale(log) yline(1, lpattern(solid) lcolor(black%90)) scheme(plottig) ///
xaxis(1 2) xline($p10 $p90 , lstyle(foreground) lcolor(gs12)) ///
xline($p25 $p50 $p75, lstyle(foreground) lcolor(gs5)) ///
xlabel($p10 "p10" $p50 "p50" $p90 "p90", axis(2) labsize(small)) xtitle("", axis(2)) ///
subtitle("$exposure; ALL_MODELS", size(small) ring(0) pos(11))
Code:
graph twoway rarea lowerM0 upperM0 $exposure, color(gs2%30) ///
|| line hrM0 hrM1 hrM2 hrM2_CC hrM2_PD $exposure, lpattern(solid) lcolor(black) lwidth(medthick) ///
legend(order(2 "M0 (95%CI)" 3 "M1" 4 "M2" 5 "M2_CC" 6 "M2_PD") ///
ring(0) bmargin(small) position(7) bmargin(large) size(small) symxsize(6.5) keygap(1.0) col(1))
ytitle("HR relative to $ref_cat") xlabel(-3.3 (0.3) -1.2) ///
yscale(log) yline(1, lpattern(solid) lcolor(black%90)) scheme(plottig) ///
xaxis(2) xline($p10 $p90 , lstyle(foreground) lcolor(gs12)) ///
xline($p25 $p50 $p75, lstyle(foreground) lcolor(gs5)) ///
xlabel($p10 "p10" $p50 "p50" $p90 "p90", axis(2) labsize(small)) xtitle("", axis(2)) ///
subtitle("$exposure; ALL_MODELS", size(small) ring(0) pos(11))
OPTION 1 Array
OPTION 2 Array
0 Response to graph twoway: two x-axis, lines and line labelling
Post a Comment