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: Unnecessary Labels for Graphs
From
Nick Cox <[email protected]>
To
[email protected]
Subject
Re: st: Unnecessary Labels for Graphs
Date
Wed, 18 Jul 2012 23:57:40 +0100
tokenize 2 5 8 9 11
foreach x of local varlist {
local call
forval j = 1/5 {
qui count if prov == ``j'' & prov_cov_`x' == 1
if r(N) > 0 local call `call' ///
(line cov_`x' date if prov == ``j'' & prov_cov_`x' ==
1, lw(thick) yvarlabel("Prov`j'"))
}
graph twoway `call'
}
On Wed, Jul 18, 2012 at 8:19 PM, Matthew Mulligan <[email protected]> wrote:
> I have to make a series of line graphs that I am hoping to use in a
> loop. Howver, for certains variables of varlist prov_cov_`x' does not
> equal one, and therefore the line does not show up on the graph. This
> was intentional as I am hoping only graph certain lines for certain
> variables. The problem is that there is still a label for that line,
> taken from the previous existing line. Without completely removing
> the legend, is there a way of forcing the label for the line that does
> not exist to not show up. I would appreciate your help. Code below:
>
> foreach x of local varlist {
> graph twoway ///
> ( line cov_`x' date if prov==2 & prov_cov_`x'==1, lwidth(thick)
> yvarlabel("Prov1")) ///
> ( line cov_`x' date if prov==5 & prov_cov_`x'==1, lwidth(thick)
> yvarlabel("Prov2")) ///
> ( line cov_`x' date if prov==8 & prov_cov_`x'==1, lwidth(thick)
> yvarlabel("Prov3")) ///
> ( line cov_`x' date if prov==9 & prov_cov_`x'==1, lwidth(thick)
> yvarlabel("Prov4")) ///
> ( line cov_`x' date if prov==11 & prov_cov_`x'==1, lwidth(thick)
> yvarlabel("Prov5"))
> }
>
*
* 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/