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: RE: Re: xtline: options for line color


From   Scott Merryman <[email protected]>
To   [email protected]
Subject   Re: st: RE: Re: xtline: options for line color
Date   Wed, 21 Jul 2010 20:31:52 -0500

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 <[email protected]> wrote:
>
> <>
>
> You could also build this from scratch as a -twoway line-, I think, using
> Scott`s techniques...
>
>
> HTH
> Martin
>
>
> -----Original Message-----
> From: [email protected]
> [mailto:[email protected]] On Behalf Of alison.drake
> Sent: Mittwoch, 21. Juli 2010 22:59
> To: [email protected]
> 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
> 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/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index