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


From   Scott Merryman <[email protected]>
To   [email protected]
Subject   Re: st: xtline: options for line color
Date   Tue, 20 Jul 2010 16:01:31 -0500

You have to use the -plot#()- option when using the -overlay- option.

For example:

webuse grunfeld, clear
gen lninvest = ln(invest)
xtline lninvest , overlay plot1(lc(blue)) plot2(lc(blue))
plot3(lc(blue)) plot4(lc(blue)) plot5(lc(blue))

Or you could use locals to gather up the plot#() options:

//Group 1, companies 1-5; Group 2 companies 6-10
forv i = 1/10 {
	if `i' < 6 {
		local plotline1  "`plotline1' plot`i'(lc(blue)) "
	}
	else {
		local plotline2 "`plotline2' plot`i'(lc(black)) "
	}
}
xtline lninvest, overlay `plotline1' `plotline2' legend(order(1 "Group
1" 6 "Group 2"))

Scott




On Tue, Jul 20, 2010 at 3:40 PM, Alison Drake <[email protected]> wrote:
> I would like to change the color of lines for subgroups on a graph generated
> by xtline.  I want to create an overlay of the lines by 2 different groups,
> group 0 and 1 and have the lines for group 0 be one color and group 1 be
> another color.  Currently, I can’t figure out how to change the line options
> unless I use a scheme, and I haven’t been able to adjust the line options by
> groups.
>
> The code I am using now (which I have also added 2 lowess curves to) shows
> the plasmaVL for each id using the sj scheme color (see below).  Can anyone
> help me get different colors of lines by group? Instead of scheme(sj) I have
> tried lcolor (green) to try to adjust the color for all, as well as lcolor
> if group==0 or if group==1 without success.  I’m not sure this is possible
> with xtline…
>
> xtset idno visitno
> xtline plasmaVL,   overlay legend(off) scheme(sj) xlabel(0(1)1)
> title("Plasma HIV viral load over time, by treatment group")  ytitle("Log10
> copies/mL") /*
> */ xtitle("Visit number")  addplot ((lowess plasmaVL visitno if group==0,
> lcolor(blue) lpattern(solid) lwidth(thick))/*
> */(lowess plasmaVL visitno if group==1, lcolor(red) lpattern(solid)
> lwidth(thick)))
>
> Thanks,
>
> Alison Drake, MPH
> Pre-doctoral Fellow
> Department of Epidemiology
> University of Washington
> Box 359909
> Seattle, WA 98195-7236
> phone: (206) 579-9211
> email: [email protected]

*
*   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