Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: Scatter plot


From   <liubaoo@sohu.com>
To   <statalist@hsphsun2.harvard.edu>
Subject   st: Scatter plot
Date   Mon, 28 Apr 2003 19:13:58 +0800 (CST)

Thanks Great Nick.

dotplot y1 y2, center mean
fit my desire perfectly.

Jeffrey

-----  Original Message  -----
From: Nick Cox 
To: statalist@hsphsun2.harvard.edu 
Subject: Re: st: Scatter plot
Sent: Sun Apr 27 23:56:43 CST 2003

> Jeffrey 
>  
> > Can anyone guide me how to draw the scatter plot of the following
> data in Stata 7.
> > (y1 vs. x1 and y2 vs. x2 in the same graph). Just the scatter plot
> rather than weighted scatter plot with weight option.
> > 
> > If the mean of y1 and y2 can be added to the graph as a line
> respectively, that will be great!
> > Thanks.
> > 
> > x1	y1	x2	y2
> > 1	10	2	10
> > 1	12	2	10
> > 1	12	2	10
> > 1	13	2	10
> > 1	15	2	10
> > 1	15	2	10
> > 1	15	2	13
> > 1	15	2	13
> > 1	15	2	12
> > 1	20	2	18
> > 1	20	2	19
> > 1	20	2	20
> > 1	20	2	11
> > 1	20	2	11
> > 1	25	2	11
> > 1	25	2	13
> > 1	29	2	14
> > 1	30	2	16
> > 1	31	2	11
> > 1	31	2	10
> > 1	32	2	12
> 
> Given these data, I suspect that you might 
> find 
> 
> dotplot y1 y2 
> 
> more informative than a scatterplot. 
> 
> But in general you would also possibly be better off 
> with a different data structure. Here is one way
> to do it in Stata 7: 
> 
> preserve             (if desired) 
> 
> gen id = _n 
> reshape long x y, i(id) 
> separate y, by(_j) 
> label var y1 "y1"
> label var y2 "y2" 
> su y1, meanonly 
> local m1 = r(mean) 
> su y2, meanonly 
> local m2 = r(mean) 
> graph y1 y2 x, yli(`m1' `m2') 
> 
> restore             (if desired) 
> 
> OR
> 
> (apart from the means) see -muxyplot- on SSC. 
> 
> Nick
> n.j.cox@durham.ac.uk
> *
> *   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/



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