Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down at the end of May, and its replacement, statalist.org is already up and running.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: st: Unnecessary Labels for Graphs


From   Nick Cox <njcoxstata@gmail.com>
To   statalist@hsphsun2.harvard.edu
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 <matt88is@gmail.com> 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/


© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index