[R] R] highlight an area below a line

Georg Otto georg.otto at tuebingen.mpg.de
Mon Mar 20 18:52:11 CET 2006


Thanks a lot for your help!

Now I have a related problem, that I still can not solve:

I plot a t distribution using:

curve(dt(x, df = 20), xlim=c(-5,5))

The upper 5% of that distribution using:

qt(0.05, df=20, lower.tail=FALSE)

How can define the polygon to highlight the area representing the
upper 5% of values?

Thanks a lot!

Georg

"Ken Knoblauch" <knoblauch at lyon.inserm.fr> writes:

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




More information about the R-help mailing list