[R] Colour area under density curve

Peter Alspach Peter.Alspach at plantandfood.co.nz
Thu Jan 27 02:03:23 CET 2011


Tena koe David

?polygon

should help you.

HTH ....

Peter Alspach

> -----Original Message-----
> From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-
> project.org] On Behalf Of David Hervas Marin
> Sent: Thursday, 27 January 2011 12:02 p.m.
> To: R-Help
> Subject: [R] Colour area under density curve
> 
> Hello,
> 
> I have this code to plot a certain normal distribution and represent
> the pnorm value for a certain "x":
> 
> 
> x<-300
> xx <- seq(2.5,7.5, by=0.1)
> yy <- dnorm(xx,5.01,0.77)
> d<-signif(pnorm(log(x), 5.01,0.77),4)
> xpts <- round(exp(0:8))
> par(bg = "antiquewhite")
> plot(xx,yy, type="l", col="blue", lwd=2, xaxt="n",
> xlab=expression(ufc/m^3),
> ylab="Densidad")
> axis(1, at=log(xpts, base=exp(1)), lab=xpts)
> n<-0
> for (i in 1:(dnorm(log(x), 5.01,0.77)/0.005)){
> n<-n+0.005
> points(log(x), n, pch=16, cex=0.3)}
> points(log(x),-0.01,pch=24,cex=2,bg='RED')
> text(log(x)+0.4, 0.004, paste(d*100, "%"))
> 
> I'd like to colour the area under the curve left to my "x". Is there
> any way?
> 
> Thanks in advance
> 
> 
> _____________________
> David Hervás Marín
> 
> 
> 
> 	[[alternative HTML version deleted]]


The contents of this e-mail are confidential and may be subject to legal privilege.
 If you are not the intended recipient you must not use, disseminate, distribute or
 reproduce all or any part of this e-mail or attachments.  If you have received this
 e-mail in error, please notify the sender and delete all material pertaining to this
 e-mail.  Any opinion or views expressed in this e-mail are those of the individual
 sender and may not represent those of The New Zealand Institute for Plant and
 Food Research Limited.



More information about the R-help mailing list