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]

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


From   Nick Cox <njcoxstata@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: graph with bars inverted for values<1
Date   Thu, 5 Apr 2012 10:34:42 +0100

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/


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