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]

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


From   <[email protected]>
To   <[email protected]>
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. 


Stephen
===========
Date: Fri, 6 Jan 2012 14:19:29 -0600
From: Scott Merryman <[email protected]>
Subject: Re: st: how to add short labels to line graphs in lieu of a
legend?

On Fri, Jan 6, 2012 at 1:00 PM,  <[email protected]> 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,
SE,
> 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
each
> 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
in
> 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
may
> 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 <[email protected]>
Subject: Re: st: how to add short labels to line graphs in lieu of a
legend?

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
plots
        . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  N.
J. Cox
        Q4/05   SJ 5(4):604--606                                 (no
commands)
        tips for using separate, gray-scale gradation, and text
        characters as class symbols to classify data points on
        a scatter plot

Nick


Stephen
------------------
Professor Stephen P. Jenkins <[email protected]>
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
2011, http://ukcatalogue.oup.com/product/9780199226436.do
Survival Analysis Using Stata:
http://www.iser.essex.ac.uk/survival-analysis
Downloadable papers and software: http://ideas.repec.org/e/pje7.html

Please access the attached hyperlink for an important electronic communications disclaimer: http://lse.ac.uk/emailDisclaimer

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