Re: [R] color under lm line

From: Eik Vettorazzi <>
Date: Tue, 15 Mar 2011 17:05:00 +0100

Hi Keith,
how about this:

fit<-function(x,coefs) x*coefs[2]+coefs[1] plot(1:10,1:10,type="n")

cf1<-c(a=3,b=.5) #eg coefs from a lm-object
cf2<-c(a=1,b=.9) #another line, coloring only intersection

setting one of the coef vectors to c(0,0) colors the area under the other line.


Am 15.03.2011 00:02, schrieb Marlin Keith Cox:
> Hi,
> I would like to add a color under a lm line and not the plotted line. Is
> this possible? In the example, I do not want the area under the curve red,
> but rather under the llm line.
> x=seq(0,5,len=100)
> y=-(x-5)^2
> llm<-lm(y~x)
> plot(x,y)
> polygon(c(x,x[length(x)]), c(y, y[1]), col='red')
> abline(llm)
> keith

Eik Vettorazzi
Institut für Medizinische Biometrie und Epidemiologie
Universitätsklinikum Hamburg-Eppendorf

Martinistr. 52
20246 Hamburg

T ++49/40/7410-58243
F ++49/40/7410-57790

______________________________________________ mailing list
PLEASE do read the posting guide
and provide commented, minimal, self-contained, reproducible code.
Received on Tue 15 Mar 2011 - 16:07:54 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 - 16:30:22 GMT.

Mailing list information is available at Please read the posting guide before posting to the list.

list of date sections of archive