[R] shading of curves with polygon

ONKELINX, Thierry Thierry.ONKELINX at inbo.be
Mon Oct 29 16:48:23 CET 2007


If min and max are two vectors with values on the y-axis and x is a vector of the values on the x-axis, then you need.

x <- 1:50
z <- matrix(rnorm(100), ncol = 2)
mini <- apply(z, 1, min)
maxi <- apply(z, 1, max)
plot(x, maxi, ylim = range(c(mini, maxi)), type = "l")
lines(x, mini)
polygon(c(x, rev(x)), c(mini, rev(maxi)), density = 100)

HTH,

Thierry


----------------------------------------------------------------------------
ir. Thierry Onkelinx
Instituut voor natuur- en bosonderzoek / Research Institute for Nature and Forest
Cel biometrie, methodologie en kwaliteitszorg / Section biometrics, methodology and quality assurance
Gaverstraat 4
9500 Geraardsbergen
Belgium 
tel. + 32 54/436 185
Thierry.Onkelinx op inbo.be 
www.inbo.be 

Do not put your faith in what statistics say until you have carefully considered what they do not say.  ~William W. Watt
A statistical analysis, properly conducted, is a delicate dissection of uncertainties, a surgery of suppositions. ~M.J.Moroney

-----Oorspronkelijk bericht-----
Van: r-help-bounces op r-project.org [mailto:r-help-bounces op r-project.org] Namens mdgi op gmx.ch
Verzonden: maandag 29 oktober 2007 16:16
Aan: r-help op stat.math.ethz.ch
Onderwerp: [R] shading of curves with polygon

Hello again

With the poylgon function it's possible to plot shaded areas under a curve.
But somehow it connects the start and the endpoint of a line and fills whats between them. I would actually like to set the boarders of the shading by two min and max curves, but I failed.

i tried stl like:

polygon(min, max, border=0), where min and max are  my curves plotet by plot(max)
lines(min)

thanks for help

marc
--
Psssst! Schon vom neuen GMX MultiMessenger gehört?
Der kann`s mit allen: http://www.gmx.net/de/go/multimessenger

______________________________________________
R-help op 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.



More information about the R-help mailing list