Re: [R] color under lm line

From: Marlin Keith Cox <marlinkcox_at_gmail.com>
Date: Mon, 14 Mar 2011 16:02:41 -0800

Thank you, but I need only the area under the llm colored. What if there were two lm lines? Is it possible to color only between them. I have search and found shaded polygons, but not shades that incorporate lm lines.

Here is the updated data example. The color on this follows both the lm and the plotted lines

x=seq(0,5,len=100)
y=-(x-5)^2
llm<-lm(y~x)
co <- coef(llm)
bord <- pmin(y, co[1] + co[2] * x)
plot(x,y)
polygon(c(x, x[length(x)]), c(bord, bord[1]), col = 'red') abline(co)

On Mon, Mar 14, 2011 at 3:24 PM, Dennis Murphy <djmuser_at_gmail.com> wrote:

> Hi:
>
> Try this:
>
> co <- coef(llm)
> bord <- pmin(y, co[1] + co[2] * x)
> plot(x,y)
> polygon(c(x, x[length(x)]), c(bord, bord[1]), col = 'red')
> abline(co)
>
> HTH,
> Dennis
>
> On Mon, Mar 14, 2011 at 4:02 PM, Marlin Keith Cox <marlinkcox_at_gmail.com>wrote:
>
>> 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

>>
>> --
>> M. Keith Cox, Ph.D.
>> Alaska NOAA Fisheries, National Marine Fisheries Service
>> Auke Bay Laboratories
>> 17109 Pt. Lena Loop Rd.
>> Juneau, AK 99801
>> Keith.Cox_at_noaa.gov
>> marlinkcox_at_gmail.com
>> U.S. (907) 789-6603
>>
>> [[alternative HTML version deleted]]
>>
>> ______________________________________________
>> 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<http://www.r-project.org/posting-guide.html>
>> and provide commented, minimal, self-contained, reproducible code.
>>
>
>

-- 
M. Keith Cox, Ph.D.
Alaska NOAA Fisheries, National Marine Fisheries Service
Auke Bay Laboratories
17109 Pt. Lena Loop Rd.
Juneau, AK 99801
Keith.Cox_at_noaa.gov
marlinkcox_at_gmail.com
U.S. (907) 789-6603

	[[alternative HTML version deleted]]

______________________________________________
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 - 00:05:44 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:30:22 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