Hi all, I want to create a simple plot with 2 type='s' lines on it: plot(a, b, type='s') lines(x, y, type='s') I wish to then fill the area between the curves with a colour to accentuate the differences eg col=gray(0.95). I cant seem to come up with a simple method for this. Any pointers in the right direction much appreciated. Cheers Scott _____________________________ Dr. Scott Williams MBBS BScMed FRANZCR Peter MacCallum Cancer Centre Melbourne, Australia scott.williams at petermac.org
Williams Scott wrote:> Hi all, > > I want to create a simple plot with 2 type='s' lines on it: > > plot(a, b, type='s') > lines(x, y, type='s') > > I wish to then fill the area between the curves with a colour to > accentuate the differences eg col=gray(0.95). I cant seem to come up > with a simple method for this. Any pointers in the right direction much > appreciated. > >I don't think there is a really simple method for this. I'd start with converting the two 's' lines to ordinary lines along the lines of N <- length(a) a1 <- c(a[1],rep(a[-1],each=2),a[N]) # possibly a[N]+a_bit for the final step) b1 <- rep(b,each=2) x1, y1 similarly, then polygon(c(a1,rev(x1)),c(b1,rev(y1), col="grey") (Did I confuse 's' and 'S'? Anyways, you get the idea)> Cheers > > Scott > _____________________________ > > Dr. Scott Williams > > MBBS BScMed FRANZCR > > Peter MacCallum Cancer Centre > > Melbourne, Australia > > scott.williams at petermac.org > > ______________________________________________ > R-help at stat.math.ethz.ch 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.dalgaard at biostat.ku.dk) FAX: (+45) 35327907
Williams Scott napsal(a):> Hi all, > > I want to create a simple plot with 2 type='s' lines on it: > > plot(a, b, type='s') > lines(x, y, type='s') > > I wish to then fill the area between the curves with a colour to > accentuate the differences eg col=gray(0.95). I cant seem to come up > with a simple method for this. Any pointers in the right direction much > appreciated. > > Cheers > > Scott > _____________________________ > > Dr. Scott Williams > > MBBS BScMed FRANZCR > > Peter MacCallum Cancer Centre > > Melbourne, Australia > > scott.williams at petermac.org > > ______________________________________________ > R-help at stat.math.ethz.ch 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. >?polygon might be useful. See also demo(graphics) Petr -- Petr Klasterecky Dept. of Probability and Statistics Charles University in Prague Czech Republic