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

st: RE: looping graph and changing title


From   "Nick Cox" <[email protected]>
To   <[email protected]>
Subject   st: RE: looping graph and changing title
Date   Tue, 3 Aug 2004 20:43:52 +0100

You need an evaluation: 

local name = country1[`y'] 

This assumes that no length limits bite. 
The longest country name I can think 
of, with a little help from 
a database, is 30 characters, e.g. 

Federated States of Micronesia

Anyone beat that? 

Nick 
[email protected] 

> -----Original Message-----
> From: [email protected]
> [mailto:[email protected]]On Behalf Of 
> R.E. De Hoyos
> Sent: 03 August 2004 20:38
> To: [email protected]
> Subject: st: looping graph and changing title
> 
> 
> How can I change the title of a graph that it is being 
> generated by a loop.
> 
> I want to define "titlename" as the string value of another 
> variable. My
> data looks like the following
> 
> country         code       var1      var2      year
> France            1            x1        y1         t
> UK                 2           x2         y2         t
> US                  3           x3        y3          t
> .                                                          ...
> 
> What I created is a graph for each country using the following loop:
> 
> levels cty, local(lev)
> qui foreach y of local lev {
>  local name "country1[`y']"
>  noi di `name'
>  #delimit ;
>  tw line var1 year if cty==`y', yaxis(1) clp(solid)  || line 
> var2 year if
> cty==`y', yaxis(2) clp(dash)
>  title("`name'") ytitle("mytitle", axis(1)) 
> ytitle("mytitle2", axis(2))
>  legend(label(1 "label1") label(2 "label2"))
>  note("mynotes");
>  noi di "Graph cty`y' Saved" ;
>  #delimit cr
> }
> 
> Although each local macro `name' displays the desired country 
> name obtained
> from the variable "country1", the graphs appear with the 
> title "country[1]"
> instead of its string (e.g. France).
> 

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