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

st: Labelling lines on graphs


From   "R. Allan Reese" <[email protected]>
To   Stata distribution list <[email protected]>
Subject   st: Labelling lines on graphs
Date   Fri, 13 Dec 2002 11:04:20 +0000 (GMT)

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

Of course, "last1" etc may be string variables to label each line with
a label sensu strictu.

R. Allan Reese                       Email: [email protected]
Associate Manager GRI                Direct voice:   +44 1482 466845
Graduate School                      Voice messages: +44 1482 466844
Hull University, Hull HU6 7RX, UK.   Fax:            +44 1482 466436
====================================================================
The management here were SO impressed with W Edward Deming's "Out of
the crisis" that they are working flat out to create THE BEST crisis,
so we can start implementing the 13 points.


*
*   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–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index