Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


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

Re: st: multiple lines on one graph using foreach


From   Scott Merryman <[email protected]>
To   [email protected]
Subject   Re: st: multiple lines on one graph using foreach
Date   Tue, 16 Mar 2010 15:30:36 -0500

Two additional ways:

webuse grunfeld,clear
levelsof com, local(levels)
foreach l of local levels {
	local gr `gr' line mval time if com == `l' ||
	}
graph twoway `gr' , legend(off) name(gr1)

//connect ascending
sort company time
line mval time, c(L) name(gr2)


Scott

On Tue, Mar 16, 2010 at 2:56 PM, Robert Song <[email protected]> wrote:
> I would like to use a foreach statement to graph ~10 different lines on a
>  single graph. But each time I do this using code below,  I generate 10
> separate graphs. Any one know how I can do this? Also how can I generate
>  a best fit line and 95% interval? I did this out longhand and it
> works... but there are a handful of graphs I need to make and it gets
> tedious.
>
> foreach ID in 1111 1112 1113 1114 1115 1116 1117 1118
> 1119 1120 1121 1122
> {
> twoway line temperature time if
> animalnumber == `ID'
> }
>
> Thanks for any help.
> -Rob
> _________________________________________________________________
> Hotmail: Trusted email with powerful SPAM protection.
> http://clk.atdmt.com/GBL/go/210850553/direct/01/
> *
> *   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/
>

*
*   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–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index