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

Research Assistant
World Bank
*   For searches and help try:

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