I personally would save a few lines of repetitive code here by using the
-eclplot- package, downloadable from SSC using the -ssc- command. As in:
sysuse auto,clear
collapse (mean) mpg (max) max = mpg (min) min = mpg, by(rep)
format mpg %9.3g
lab def replab 1 "Fakult 1" 2 "Fakult 2" 3 "Fakult 3" 4 "Fakult 4" 5
"Facu;t 5"
lab val rep replab
eclplot mpg min max rep, horiz eplottype(bar) rplottype(rcap) ///
supby(rep) ciopts(lcolor(black)) ///
plot(scatter rep mpg, msym(none) mlab(mpg) mlabpos(11)
mlabcolor(black))
The -eclplot- command can produce 56 types of confidence interval plot
(or range plot), some of which are more useful than others, but all of
which can be horizontal or vertical.
I hope this helps.
Roger
Roger Newson
Lecturer in Medical Statistics
Respiratory Epidemiology and Public Health Group
National Heart and Lung Institute
Imperial College London
Royal Brompton campus
Room 33, Emmanuel Kaye Building
1B Manresa Road
London SW3 6LR
UNITED KINGDOM
Tel: +44 (0)20 7352 8121 ext 3381
Fax: +44 (0)20 7351 8322
Email: [email protected]
www.imperial.ac.uk/nhli/r.newson/
Opinions expressed are those of the author, not of the institution.
-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of
[email protected]
Sent: 09 January 2007 20:58
To: [email protected]
Subject: Re: st: labeling bars with twoway bar and rcap
One way would be to use -scatter , mlab()-
For example:
sysuse auto,clear
collapse (mean) mpg (max) max = mpg (min) min = mpg, by(rep)
format mpg %9.3g
twoway bar mpg rep if rep == 1 , horiz || ///
bar mpg rep if rep == 2 , horiz || ///
bar mpg rep if rep == 3 , horiz || ///
bar mpg rep if rep == 4 , horiz || ///
bar mpg rep if rep == 5 , horiz || ///
rcap max min rep , horiz lcolor(black) || ///
scatter rep mpg, msym(none) mlab(mpg) mlabpos(11) mlabcolor
(black) ///
legend(order(1 "Fakult 1" 2 "Fakult 2" 3 "Fakult 3" 4 "Fakult 4" ))
Scott
----- Original Message -----
From: Daniel Becker <[email protected]>
Date: Tuesday, January 9, 2007 1:07 pm
Subject: st: labeling bars with twoway bar and rcap
To: [email protected]
> Dear statalist,
>
> the following command gives me the plot you can see here:
> http://www.wiwi.uni-rostock.de/~wsf8545/test.png
>
>
> graph twoway
> (bar meanwrite Z_faks if Z_faks==0, horizontal)
> (bar meanwrite Z_faks if Z_faks==1, horizontal)
> (bar meanwrite Z_faks if Z_faks==2, horizontal)
> (bar meanwrite Z_faks if Z_faks==3, horizontal)
> (rcap hiwrite lowrite Z_faks, lwidth(thick) lcolor(black)
horizontal),
> legend(order(1 "Fakult 1" 2 "Fakult 2" 3 "Fakult 3" 4 "Fakult 4" )
>
> cols(1) width(100));
>
> Is it possible to label the bars? Such that the upper yellow bar
> has
> a 3.8 somewhere, the lower blue one a 3.5 etc.
>
> I tried to use blabel(), searched the web, but to no avail.
>
> Thanks for your help.
>
> Daniel
*
* For searches and help try:
* http://www.stata.com/support/faqs/res/findit.html
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/
*
* For searches and help try:
* http://www.stata.com/support/faqs/res/findit.html
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/