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]

Re: st: scatter plot with lines laid on


From   Maarten buis <[email protected]>
To   [email protected]
Subject   Re: st: scatter plot with lines laid on
Date   Mon, 21 Mar 2011 08:51:42 +0000 (GMT)

--- On Mon, 21/3/11, Jian Zhang wrote:
> Hi all, I was graphing a scatter plot with a number of
> values for x in the x-axis.  What I'd like to do is to lay
> on the scatter plot three lines: one line connecting the
> means of y at each value of x and two lines connecting the
> one standard deviation above and below the means of y at
> each value of x, respectively. Does anyone know how to do
> this?  

What about this:

*--------------- begin example --------------
sysuse auto, clear

bys rep78: egen m = mean(price)
bys rep78: egen sd = sd(price)
gen lb = m - sd
gen ub = m + sd

twoway rarea lb ub rep78, astyle(ci) || ///
       line m rep78, lstyle(p1)      || ///
       scatter price rep78, msymbol(Oh) 
*-------------- end example -----------------
(For more on examples I sent to the Statalist see: 
http://www.maartenbuis.nl/example_faq )

Hope this helps,
Maarten

--------------------------
Maarten L. Buis
Institut fuer Soziologie
Universitaet Tuebingen
Wilhelmstrasse 36
72074 Tuebingen
Germany

http://www.maartenbuis.nl
--------------------------


      

*
*   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–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index