Re: [R] Shade area under curve?

About this list Date view Thread view Subject view Author view Attachment view

From: Ben Bolker (ben@zoo.ufl.edu)
Date: Thu 31 Jan 2002 - 02:40:37 EST


Message-id: <Pine.LNX.4.30.0201301038140.29758-100000@bolker.zoo.ufl.edu>


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@stat.math.ethz.ch
> _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
>

-- 
318 Carr Hall                                bolker@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@stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._


About this list Date view Thread view Subject view Author view Attachment view

This archive was generated by hypermail 2.1.3 : Wed 16 Oct 2002 - 11:56:55 EST