Statalist


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

Re: st: Graph bar question


From   Maarten buis <[email protected]>
To   [email protected]
Subject   Re: st: Graph bar question
Date   Fri, 9 Jan 2009 20:10:30 +0000 (GMT)

--- Ricardo Ovaldia <[email protected]> wrote:
> I am graphing the mean concentration of a substance over three
> variables using -graph bar, over()-. I would like to have the number
> of observations (N) for each bar listed on top of the bar. Can I do
> that in Stata?

If I can't do something in -graph bar- I always move to -twoway-. You
can probably do what you want using -graph bar- as -graph bar- allows
the -text()- option, but below I give you a solution using -twoway
bar-:

*---------------- begin example --------------------
sysuse auto, clear
recode rep78 1/2=3
collapse (mean) price (count) N=price, by(rep78)
gen y = price + 150
twoway bar price rep78,    ///
      barw(.5) ||          ///
      scatter y rep78,     ///
      mlab(N) mlabpos(0)   ///
      msymbol(i)           ///
      ylab(0(2500)7500)    ///
      xlab(3 "medium"      ///
           4 "good"        ///
           5 "excelent")   ///
      ytitle("mean price") /// 
      legend(off)          ///
      xscale(range(2.5 5.5))
*-------------- end example -----------------------

Hope this helps,
Maarten

-----------------------------------------
Maarten L. Buis
Department of Social Research Methodology
Vrije Universiteit Amsterdam
Boelelaan 1081
1081 HV Amsterdam
The Netherlands

visiting address:
Buitenveldertselaan 3 (Metropolitan), room N515

+31 20 5986715

http://home.fsw.vu.nl/m.buis/
-----------------------------------------


      
*
*   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–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index