David Kaplan wrote:
Hi all,

Apologies in advance if this is really too simple, but I have given a good shot at this. I'm generating a standard uniform distibution

y <- dunif(x)
plot(x,y,type="l")

This will draw a horizontal line at y = 1. I want to fill the area from x=(0,1) with a color. I've tried the polygon command to create a polygon of the same shape, but can't seem to set the parameters to fill the figure from x=(0,1). I'm sure there is an easy way to do this, but any advice would be welcome.

Thanks in advance.

Something like

x <- seq(0,1,,10)
y <- dunif(x)
plot(x,y, ylim=range(0,y))
polygon(c(0,x,1), c(0,y,0), col="red", border=NA)


David

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


--
   O__  ---- Peter Dalgaard             Ă˜ster Farimagsgade 5, Entr.B
  c/ /'_ --- Dept. of Biostatistics     PO Box 2099, 1014 Cph. K
 (*) \(*) -- University of Copenhagen   Denmark      Ph:  (+45) 35327918
~~~~~~~~~~ - (p.dalga...@biostat.ku.dk)              FAX: (+45) 35327907

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to