Bookmark and Share

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


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

st: Box Graph Question


From   John Marvel <[email protected]>
To   [email protected]
Subject   st: Box Graph Question
Date   Tue, 8 Oct 2013 16:15:29 -0400

My question refers to a statalist posting under the same subject line
as above ("Box Graph Question") from November 1, 2006.  I'm running
Stata 13 SE.

The code below (from Nick Cox) produces a very useful graph of
descriptive statistics.

My question is whether the elements of the graph (the bars) can be
ordered by mean.  In other words, if I wanted the bars that the code
produces to run from the lowest mean to the highest mean, how would I
do that (if possible?).

Thanks very much for any help,

John Marvel

****************************************************
sysuse auto, clear

statsby "su mpg" mean=r(mean) max=r(max) min=r(min) sd=r(sd), by(rep78)

gen meanpsd = mean + sd
gen meanmsd = mean - sd

twoway scatter mean rep78 || ///
rbar mean max rep78, bcolor(none) barw(0.2) || ///
rbar mean min rep78, bcolor(none) barw(0.2) || ///
rbar meanmsd meanpsd rep78 , barw(0.1) bcolor(red) ///
legend(off) ytitle(Miles per gallon) yla(, ang(h)) ///
note(red bars: mean +/- sd; empty bars show range)
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index