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: RE: complicated scatterplot with connected points


From   Nick Cox <[email protected]>
To   "'[email protected]'" <[email protected]>
Subject   st: RE: complicated scatterplot with connected points
Date   Fri, 3 Dec 2010 17:44:46 +0000

There are various approaches to this. One is to restructure your data so that the graphics command becomes easier. 

preserve 
reshape long x y, i(city) 

Spelling is Stata. 

Nick 
[email protected] 

Gisella Young 

I want to draw a slightly complex scatterplot in STATA and have not been able to find a way how. For each city I have 3 points (each with a x- and y-coordinate) for 3 different years. I can use the -twoway- graphics command to do three overlaid scatterplots so that each city has 3 points, one for each year. The tricky part: to CONNECT (with a line) the three points for each city, so as to trace its path over time.

The command I am using at the moment, for the basic scatterplot without connecting lines, is:
 twoway (scatter x y1, sort mlabel(city1)) (scatter x2 y2, sort mlabel(city2)) (scatter x3 y3, sort mlabel(city3))


My data has the following structure:

city        x1   y1   x2    y2    x3   y3   city1      city2      city3

Portland    34   64   23    78    54   67   Portland1  Portland2  Portland3
Chicago     53   72   33    52    91   77   Chicago1   Chicago2   Chicago3
Boston      etc


I would greatly appreciate any suggestions. Thank you!


*
*   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