Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down at the end of May, and its replacement, statalist.org is already up and running.


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

st: changing bar order on twoway bar chart


From   Ben Cooper <ben.cooper@wustl.edu>
To   "statalist@hsphsun2.harvard.edu" <statalist@hsphsun2.harvard.edu>
Subject   st: changing bar order on twoway bar chart
Date   Tue, 18 Sep 2012 18:14:15 +0000

Hello,

I have a graph dilemma that I can not solve. I have successfully used the syntax below from the URL (http://www.survey-design.com.au/Stata%20Graphs.html) to create a two-way horizontal bar chart depicting odds ratios and CIs above and below the value of 1.

twoway bar  estimate axis, base(1) horizontal barw(.70) color("0 0 192") scheme(s1color) ///
            xline(1) ylab(, valuelabel angle(0)) ||     ///
            rcap min95 max95 axis, horizontal  lwidth(medthick) lcolor("255 127 0") msize(large) ///
            title("Outcome: Disconnected")  ///
            legend(order(1 "point estimate" 2 "95% CI") pos(6))             

The problem is that Stata sorts the bars in order of the magnitude of the odds ratio and this simply will not work for my project. I know I can do custom bar sorting with the 'graph hbar x, over(y)' command but then I lose the ability to use the rcap option for error bars and the base(1) option to set the bars starting at 1 (since they are ORs). I have tried creating each bar separately and putting all on one graph but Stata still continues to sort the bars based on the value in the variable estimate. I certainly like all the features of the twoway bar approach, except this one issue of not being able to sort the bars. However, at this point, I am open to any and all suggestions or approaches.

Thanks,
Ben


*
*   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/


© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index