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 on April 23, and its replacement, statalist.org is already up and running.


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

st: Unnecessary Labels for Graphs


From   Matthew Mulligan <matt88is@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   st: Unnecessary Labels for Graphs
Date   Wed, 18 Jul 2012 15:19:24 -0400

Dear Statalist

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"))
}


Matt
Research Assistant
World Bank
*
*   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