Re: [R] color under lm line

From: Dieter Menne <dieter.menne_at_menne-biomed.de>
Date: Tue, 15 Mar 2011 06:21:35 -0700 (PDT)

Marlin Keith Cox wrote:
>
> Thank you, but I need only the area under the llm colored. What if there
> were two lm lines?
>
For the well-behaved case you could find the range to be colored with

range = which(diff(resid(llm)>0)!=0)

Dieter

x=seq(0,5,len=100)
y=-(x-5)^2
llm<-lm(y~x)
range = which(diff(resid(llm)>0)!=0)
co <- coef(llm)
bord <- pmin(y, co[1] + co[2] * x)
plot(x,y)
r1 = range[1]
r2 = range[2]
polygon(c(x[r1],x[r1],x[r2],x[r2]),

        c(min(y),y[r1],y[r2],min(y)),
        col = 'red')

abline(co)
--
View this message in context: http://r.789695.n4.nabble.com/color-under-lm-line-tp3355317p3356538.html
Sent from the R help mailing list archive at Nabble.com.

______________________________________________
R-help_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Received on Tue 15 Mar 2011 - 13:24:33 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Tue 15 Mar 2011 - 13:40:21 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive