Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

From |
"Mills, Michael" <mmills@rti.org> |

To |
<statalist@hsphsun2.harvard.edu> |

Subject |
st: Graph overlay marker labels over bars and lines |

Date |
Fri, 17 Feb 2012 13:33:26 -0500 |

I have seen similar questions and replies on overlaying graphs, but nothing that has solved my particular problem, so I apologize if this is already out there. I have a graph overlaying line graphs (of outcome means) over bar charts (of sample Ns, which works fine (through the xtitle(`:variable label adj_time') line. These graphs are produced for a number of variables (varname shortened to `stub') and thresholds (`thresh') and over various ranges on outcomes (which is by `amin' and `amax' are used to control what portion of the x-axis is displayed/labeled in each graph and similarly `rmin'/`rmax' for the y-axis; atime2 and atime3 are offsets of adj_time to make the bar graphs pretty). I am adding to this chart labels at the top of the bar charts showing "n = #" (for n <= 5; contained in the barlab... variables). The scatter code below works, however the marker labels ("n = #")that are displayed are displayed underneath the lines (but above the bar charts) limiting readability of the marker labels in instances when lines cross over the marker labels. Is there a way to get the marker labels to be in front of the lines rather than covered up by the lines? I have tried adjusting the placement/ordering of the scatter... lines within the twoway code to no avail. twoway bar n_`stub'_`thresh'_s atime2 if atime2>=`amin'-.5 & atime2<=`amax'+.5 & ``i''>=`thresh', barw(0.3) yaxis(2) color(eltblue) || bar n_`stub'_`thresh'_ns atime3 if atime3>=`amin'-.5 & atime3<=`amax'+.5 & ``i''>=`thresh', barw(0.3) yaxis(2) color(erose) || line mean_`stub'_`thresh'_s mean_`stub'_`thresh'_ns adj_time if adj_time>=`amin' & adj_time<=`amax' & ``i''>=`thresh', lcolor(blue red) yaxis(1) xaxis(1 2) xline(8, lpattern(dash) lcolor(gs12)) title("Quarterly Mean of `: variable label `var''" "by Quarter Relative to Adjustment Date", size(small)) xlabel(`amin'(1)`amax', valuelabel angle(60) axis(1) labsize(vsmall)) xtitle(, axis(1) size(small)) xlabel("", axis(2)) xtitle("", axis(2)) ylabel(, angle(0) labsize(vsmall)) ytitle("`: variable label `var''", size(small)) yscale(alt r(`rmin' `rmax')) ylab(#6, axis(1) labsize(small)) yscale(alt axis(2) r(0 40)) ylab(#6, axis(2) angle(0) labsize(small)) ytitle("Number of groups" "Included In Each Time Period", axis(2) size(small)) xtitle(`:variable label adj_time') || scatter n_`stub'_`thresh'_ns atime3 if atime3>=`amin'-.5 & atime3<=`amax'+.5 & ``i''>=`thresh' & n_`stub'_`thresh'_ns<= 5, ms(none) mlab(barlab_`stub'_`thresh'_ns) mlabcolor(black) mlabgap(*-.5) mlabpos(12) yaxis(2) mlabsize(*.6) || scatter n_`stub'_`thresh'_s atime2 if atime2>=`amin'-.5 & atime2<=`amax'+.5 & ``i''>=`thresh' & n_`stub'_`thresh'_s <= 5, ms(none) mlab(barlab_`stub'_`thresh'_s) mlabcolor(black) mlabgap(*-.5) mlabpos(12) yaxis(2) mlabsize(*.6) legend(order(5 6 1 2) size(vsmall)) Thanks, - Mike * * For searches and help try: * http://www.stata.com/help.cgi?search * http://www.stata.com/support/statalist/faq * http://www.ats.ucla.edu/stat/stata/

- Prev by Date:
**st: inverse logit of gamma and xtfrontier** - Next by Date:
**st: survival analysis help** - Previous by thread:
**st: inverse logit of gamma and xtfrontier** - Next by thread:
**st: survival analysis help** - Index(es):