[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

From |
"Allan Reese (Cefas)" <allan.reese@cefas.co.uk> |

To |
<statalist@hsphsun2.harvard.edu>, <gisellayoung@yahoo.com> |

Subject |
RE: statalist-digest V4 #3517 (Re: st: how to have legend as labels on graph) |

Date |
Mon, 17 Aug 2009 12:04:53 +0100 |

My approach to this for a long time has been to generate a label variable for each Y variable and set all but one value to missing. Using the example data generated by Martin Weiss: gen x1lab="Arizona" if time==100 /* and similar for x2lab, x3lab */ scatter x1 x2 x3 time, c(l l l) mlab(x1lab x2lab x3lab) xscale(range(0 110)) legend(off) * Adds a label at the end of each line respectively, with the xrange extended to fit them in the plot area. The approach can be generalized to put the label by the maximum on each line. egen x1max = max(x1) gen alt1 = "Arizona" if x1==x1max /* & hand edit the data if multiple maxima in data. scatter x1 x2 x3 time, c(l l l) mlab(alt1 x2lab x3lab) mlabpos(12) xscale(range(0 110)) legend(off) Using the standard features of - twoway scatter - you can have markers, connect lines or both, and vary the position of each line label relative to its associated datum: scatter x1 x2 x3 time, c(l l l) mlab(alt1 x2lab x3lab) mlabpos(12 6 3) xscale(range(0 110)) legend(off) The approach is useful because it's data driven - it won't put the label by the wrong line because of my typos! So it's a good analytic approach but for presentation one would probably want to nudge the labels using the graph editor. Allan Original question: Date: Fri, 14 Aug 2009 08:26:14 -0700 (PDT) From: Gisella Young <gisellayoung@yahoo.com> Subject: st: how to have legend as labels on graph A simple question. I have a simple line graph with multiple lines on it (one line for each province, showing a single variable over time for each). Having a legend is confusing as the chart will be in B&W and there are a number of lines so, even with different line styles, it is difficult to see which is which. What I want is to have the labels on the chart itself, next to each line (e.g. on the right hand side), i.e. next to each line to have the name of the province which it's for. I've tried and tried but am unable to do this, is it possible??? Thank you! Gisella ------- *********************************************************************************** This email and any attachments are intended for the named recipient only. Its unauthorised use, distribution, disclosure, storage or copying is not permitted. If you have received it in error, please destroy all copies and notify the sender. In messages of a non-business nature, the views and opinions expressed are the author's own and do not necessarily reflect those of the organisation from which it is sent. All emails may be subject to monitoring. *********************************************************************************** * * 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/

- Prev by Date:
**Re: st: Problem with outreg2 after negative binomial regression** - Next by Date:
**AW: st: Problem with outreg2 after negative binomial regression** - Previous by thread:
**st: RE: statalist-digest V4 #3517 (was Re: Flexible end of numlist)** - Next by thread:
**st: RE: how to check that demographic values within the same zipcode are identical?** - Index(es):

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