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

st: looping graph and changing title


From   "R.E. De Hoyos" <redeho@hotmail.com>
To   <statalist@hsphsun2.harvard.edu>
Subject   st: looping graph and changing title
Date   Tue, 3 Aug 2004 20:37:48 +0100

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).

Any thoughts?

Many thanks,

Rafa

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