Statalist


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

st: Linking legend text to the value of a variable


From   Dorothy Bridges <dbstata@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   st: Linking legend text to the value of a variable
Date   Thu, 1 Oct 2009 08:51:28 -0400

Dear Statalist:

I have a loop creating twoway graphs along the lines of the following:

levels idvar, local(ID)
foreach i of local ID{
#delimit;
di "`i'";
twoway (line yvar xvar if idvar=="`i'" & idvar2==1 & idvar3==1, lpattern(dash))
(line yvar xvar if idvar=="`i'" & idvar2==2 & idvar3==1, lpattern(dash))
(line yvar2 xvar2 if idvar=="`i'" & idvar2==1 & idvar3==1, color(navy)
yaxis(2) lpattern(dash))
title("`i')
};

And I would like the legend to be: legend(label(1 =idvar2_name if
idvar=="`i'" & idvar2==1 & idvar3==1) label(2 =idvar2_name if
idvar=="`i'" & idvar2==2 & idvar3==1))

How might I accomplish this?  I found this
(http://www.stata.com/statalist/archive/2004-03/msg00129.html) in the
archive but couldn't quite get from there to where I would like to be.

Thank you!
*
*   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   |   What's new   |   Site index