[R] Shade area under curve?

Ben Bolker ben at zoo.ufl.edu
Wed Jan 30 16:40:37 CET 2002


plot(dnorm,-4,4)
xvals <- seq(-2,2,length=50)
dvals <- dnorm(xvals)
polygon(c(xvals,rev(xvals)),c(rep(0,50),rev(dvals)),col="gray")

On Wed, 30 Jan 2002, Robert Lundqvist wrote:

> Hi all,
>
> I've got this graphics question which really should be easy. I want to shade
> an area between bounds under a curve. A suitable beginning seems to be the
> following:
>
> > plot(dnorm,-4,4)
> > segments(-4,0,4,0)
> > segments(-2,0,-2,dnorm(-2))
> > segments(2,0,2,dnorm(2))
>
> It is the area between -2 and 2 which I want to shade (or something
> similar). Hints anyone?
>
> Robert
> ****************
> Robert Lundqvist
> Dept of Quality Technology & Statistics
> Lulea University of Technology
> Sweden
> -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
> r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
> Send "info", "help", or "[un]subscribe"
> (in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
> _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
>

-- 
318 Carr Hall                                bolker at zoo.ufl.edu
Zoology Department, University of Florida    http://www.zoo.ufl.edu/bolker
Box 118525                                   (ph)  352-392-5697
Gainesville, FL 32611-8525                   (fax) 352-392-3704

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list