[R] R] highlight an area below a line

Ken Knoblauch knoblauch at lyon.inserm.fr
Wed Mar 15 01:40:51 CET 2006


How about,

d<-density(rnorm(10000))
plot(d)
wvs <- which(d$x > 1 & d$x < 2)
polygon(d$x[c( wvs[1], wvs, wvs[length(wvs)] ) ], c(0, d$y[wvs], 0), col =
"bisque")

Georg Otto a écrit:
Hi,

if I plot a normal distribution like this:

d<-density(rnorm(10000))
plot(d)

how can I highlight the area below the graph in a certain interval,
say x=1,2?  I understand that I should use polygon, but I have not
found the right way to give the result that I want.

Thanks a lot!

Georg
-- 
Ken Knoblauch
Inserm U371
Cerveau et Vision
Dept. of Cognitive Neuroscience
18 avenue du Doyen Lépine
69500 Bron
France
tel: +33 (0)4 72 91 34 77
fax: +33 (0)4 72 91 34 61
portable: +33 (0)6 84 10 64 10
http://www.lyon.inserm.fr/371/




More information about the R-help mailing list