Allan Reese:
> Nick Cox suggests that multiple lines can be distinguished by line style
> and a key. Here's another alternative, offered to underline one reason
> for advocating Stata as a graphics tool: its facility for creating and
> revising graphics in a design-review-edit cycle.
>
> Given several series, var names ser1, ser2, ser3 etc ...
>
> gr ser1 ser2 year, s(..) c(ll) /* simple line graph */
>
> gen id1=1
> gen id2=2 /* etc */
> gr ser1 ser2 year, s([id1][id2]) c(ll) /* labels every point */
> /* may be too cluttered if there are many points */
>
> gen last1=1 if(_n==_N)
> gen last2=2 if(_n==_N) /* etc */
> gr ser1 ser1 ser2 ser2 year, s(.[last1].[last2]) c(l.l.) pen(2233)
> /* puts a label at the end of each line, in same colour as line */
> /* but beware if _Nth value of series is missing! */
and, as further extension (the _Nth value is not missing):
local n = _N + 1
set obs n
gen last1 = ser1[_N-1] if _n==_N
gen last2 = ser2[_N-1] if _n==_N
gen lab1 = 1 if (_n==_N)
gen lab2 = 2 if (_n==_N)
replace year = year[_N-1] + 1 if _n==_N
gr ser1 last1 ser2 last2 year, s(i[lab1]i[lab2]) c(l.l.) pen(2233)
Change the "+1" in the replace command to move the description in the space
of the x-axis. Of course, "lab1" etc may be string variables to label each
line with a label sensu strictu.
*
* 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/