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

st: Re: RE: looping graph and changing title


From   "R.E. De Hoyos" <[email protected]>
To   <[email protected]>
Subject   st: Re: RE: looping graph and changing title
Date   Tue, 3 Aug 2004 20:55:16 +0100

Thanks Nick,

However I tried that (without double quotes) and the outcome is:
France not found       //Which happened to be the first country in the list
r(111);

When I include quotes, i.e. local name = "coutnry1[`y']", countries are
properly displayed but they do NOT appear in the graph title. The titles
still display "country1[1]" as a title for France.

Rafa

----- Original Message -----
From: "Nick Cox" <[email protected]>
To: <[email protected]>
Sent: Tuesday, August 03, 2004 8:43 PM
Subject: st: RE: looping graph and changing title


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