Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
From | "alison.drake" <adrake2@u.washington.edu> |
To | statalist@hsphsun2.harvard.edu |
Subject | st: RE: Re: xtline: options for line color |
Date | Thu, 22 Jul 2010 14:12:06 -0700 (PDT) |
Thanks so much this worked! From: Scott Merryman [via Statalist] [mailto:ml-node+5323657-1983656536-608019@n2.nabble.com] Sent: Wednesday, July 21, 2010 6:33 PM To: alison.drake Subject: RE: Re: xtline: options for line color Something like this: clear set obs 150 gen id = _n expand 30 bys id: gen t = _n gen group = (id<=75) gen x = rnormal() if gr == 0 replace x = rnormal(4,1) if gr == 1 forv i = 1/150 { if `i' < 76 { local plotline1 "`plotline1' line x t if id == `i', lc(black) || " } else { local plotline2 "`plotline2' line x t if id == `i', lc(blue) || " } } twoway `plotline1' `plotline2' , legend(order(1 "Group 1" 76 "Group 2")) Scott On Wed, Jul 21, 2010 at 4:15 PM, Martin Weiss <[hidden email]> wrote: > > <> > > You could also build this from scratch as a -twoway line-, I think, using > Scott`s techniques... > > > HTH > Martin > > > -----Original Message----- > From: [hidden email] > [mailto:[hidden email]] On Behalf Of alison.drake > Sent: Mittwoch, 21. Juli 2010 22:59 > To: [hidden email] > Subject: st: Re: xtline: options for line color > > I tried the plotline option (suggested by Scott) but I got an error saying > "too many options". I think because I have 150 ID's, so I would have to > individually overlay 150 plots. This doesn't seem to be a problem with just > the xtline command with an overlay option, but is with the plot() option. > > The individual plot() commands are cumbersome since I have so many groups, > and I think I might have the "too many options" problem I encountered with > the loop. > > I have also been digging deeper into the archives and tried to use the > linkplot, but can't find a way to get separate colors for different groups. > Below please find a subset of my data below for additional reference: > > Essentially, I want every id to have it's own line graphed, but the color > should vary based on the group variable (all group 0 are blue, group 1=red, > for example). The visit is my time variable and vl is my yvariable. As you > can see, the data is set up in long format, but I also have it in wide. > > Any other suggestions on how to do this? > Thanks, > Alison > > group visit vl id > 0 0 5.221649 1 > 0 1 4.686413 1 > 1 0 5.174583 2 > 1 1 4.065019 2 > 1 0 2.720159 3 > 1 1 2.09691 3 > 1 0 4.345472 4 > 1 1 3.639984 4 > 1 0 4.234644 5 > 1 1 3.279895 5 > 1 0 2.09691 7 > 1 1 2.09691 7 > 1 0 3.385606 8 > 1 1 3.557507 8 > 1 0 4.165541 9 > 1 1 4.279781 9 > 1 0 3.987666 10 > 1 1 3.469085 10 > 1 0 4.307924 11 > 1 1 3.472756 11 > 0 0 5.521073 14 > 0 1 4.902003 14 > > > -- > View this message in context: > http://statalist.1588530.n2.nabble.com/xtline-options-for-line-color-tp53184 <http://statalist.1588530.n2.nabble.com/xtline-options-for-line-color-tp53184?by-user=t> > 43p5322903.html > Sent from the Statalist mailing list archive at Nabble.com. > * > * 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/ > * * 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/ _____ View message @ http://statalist.1588530.n2.nabble.com/xtline-options-for-line-color-tp5318443p5323657.html To unsubscribe from Re: xtline: options for line color, click < (link removed) > here. -- View this message in context: http://statalist.1588530.n2.nabble.com/xtline-options-for-line-color-tp5318443p5327292.html Sent from the Statalist mailing list archive at Nabble.com. * * 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/