Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at

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

Re: st: how to add short labels to line graphs in lieu of a legend?

From   <>
To   <>
Subject   Re: st: how to add short labels to line graphs in lieu of a legend?
Date   Mon, 9 Jan 2012 09:31:30 -0000

Many thanks to Scott Merryman for pointing out my Friday evening
blindness: as he surmised, creating appropriate non-missing values of
variable qdate solved my problem, and my graph was drawn as desired.

Many thanks too to Nick Cox for his helpful tip about another way of
approaching the problem. 

Date: Fri, 6 Jan 2012 14:19:29 -0600
From: Scott Merryman <>
Subject: Re: st: how to add short labels to line graphs in lieu of a

On Fri, Jan 6, 2012 at 1:00 PM,  <> wrote:
> I have quarterly data for a panel of 6 countries (DE, IE, IT, SE, UK,
> US)  which begin in 2007q1 and run until 2011q3 for 4 countries (DE,
> UK, US), but only to 2011q2 for IE and IT
> I am graphing a variable "index" against time for each country
> separately, and want to add a country marker label to the right of
> country's series that shows the relevant country's 2-letter acronym
> (held in string var "cty2").  I want the country marker labels to be
> the same position relative to the horizontal axis -- i.e. all the
> country labels should be vertically aligned, even for the 2 countries
> with shorter series.
> [I currently also identify the separate series using a legend, but I
> drop that if I can solve my problem.]
> The problem is that I can't get the marker labels shown for IE and IT
> (the 2 countries with shorter series), let alone aligned.

Date: Fri, 6 Jan 2012 19:51:44 +0000
From: Nick Cox <>
Subject: Re: st: how to add short labels to line graphs in lieu of a

I use -text()- for this purpose. For example,

separate index, by(cty2) veryshortlabel
bysort cty2 (qdate) : gen last = index[_N]
local options
foreach cty in DE IE IT SE UK US {
    su last if cty2 == "`cty'", meanonly
    local options `options' text(`r(max)' 206 "`cty'", place(e))

di `"`options'"'

line index? qdate, `options' xsc(r(. 207)) legend(off)

See also

SJ-5-4  gr0023  . . . . Stata tip 27: Classifying data points on scatter
        . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  N.
J. Cox
        Q4/05   SJ 5(4):604--606                                 (no
        tips for using separate, gray-scale gradation, and text
        characters as class symbols to classify data points on
        a scatter plot


Professor Stephen P. Jenkins <>
Department of Social Policy and STICERD
London School of Economics and Political Science
Houghton Street, London WC2A 2AE, UK
Tel: +44(0)20 7955 6527
Changing Fortunes: Income Mobility and Poverty Dynamics in Britain, OUP
Survival Analysis Using Stata:
Downloadable papers and software:

Please access the attached hyperlink for an important electronic communications disclaimer:

*   For searches and help try:

© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index