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

# Re: st: graph with bars inverted for values<1

 From Shehzad Ali To "statalist@hsphsun2.harvard.edu" Subject Re: st: graph with bars inverted for values<1 Date Thu, 5 Apr 2012 18:33:53 +0100 (BST)

```Thanks, Nick. Very helpful.

>________________________________
> From: Nick Cox <njcoxstata@gmail.com>
>To: statalist@hsphsun2.harvard.edu
>Sent: Thursday, 5 April 2012, 10:34
>Subject: Re: st: graph with bars inverted for values<1
>
>The answer to (1) is to use the -base()- option.
>
>Some graphical technique for (2) follows. You just need to create
>variables with the positions you want and the text you want.
>
>sysuse auto, clear
>egen meanmpg = mean(mpg) , by(rep78)
>su mpg
>local mean = r(mean)
>gen pos = cond(meanmpg > `mean', meanmpg + 0.3, meanmpg - 0.3)
>gen show = string(meanmpg, "%2.1f")
>twoway bar meanmpg rep78, base(`mean') barw(0.5) ///
>|| scatter pos rep78, mla(show) mlabpos(0) ms(none) ///
>ytitle("`: var label mpg'") legend(off)
>
>Nick
>
>On Thu, Apr 5, 2012 at 10:17 AM, Shehzad Ali <drshehzad_ali@yahoo.com> wrote:
>
>> I have the following bar graph with confidence intervals:
>>
>> twoway (bar coefficient xvar) (rcap lowerCI upperCI xvar)
>>
>> I was wondering if its possible:
>>
>>
>> 1. To make a bar graphwith erected bars for values>1 and inverted bars for values <1 with horizontal line at 1. I have odds ratios that I want to represent in this manner.
>>
>> 2. Also, is it possible to add values on top of the bar for the erected bars and just below the inverted bars?
>*
>*   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/
>
>
>

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