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

st: Re: How to suppress legend keys


From   Friedrich Huebler <[email protected]>
To   [email protected]
Subject   st: Re: How to suppress legend keys
Date   Wed, 9 Apr 2003 20:18:36 -0700 (PDT)

--- Scott Merryman <[email protected]> wrote:
> > Is it possible to instruct Stata to only show keys for data
> > that appears in the graph?
>
> This will only show the legend for only the second variable:
> 
> twoway (scatter h r mp), legend(order(2 "Repair 1978"))

Scott,

Thank you for the suggestion but this does not quite help me. I am
creating time series graphs for several dozen countries with a
-foreach- loop and need a catchall command that does not require me
to know in advance which legend keys should appear in which graph.

Here is an abbreviated excerpt from my command (I use ; as a
delimiter). The variable "country" contains the country name, "year"
is the year, and "var_a" and "var_b" are time series variables. The
macro "countries" contains the names of the countries for which I
need graphs.

foreach x of local countries {;
  scatter var_a year if country=="`x'", connect(l) ||
  scatter var_b year if country=="`x'", connect(l);
  graph export "`x'.wmf";
  };

If var_a or var_b have no values, no lines will be plotted. However,
there is still a legend with entries for var_a and var_b. I want to
suppress the respective legend key if a time series does not appear
in the graph. How can this be done? Is there a kind of "legend if
var_a<." command? At least one of my time series always has data, so
there are no completely empty graphs.

Friedrich Huebler

__________________________________________________
Do you Yahoo!?
Yahoo! Tax Center - File online, calculators, forms, and more
http://tax.yahoo.com
*
*   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