[R] fill between lines

ivo welch ivo.welch at yale.edu
Mon Apr 19 20:16:26 CEST 2004

hi:  is it possible to color areas between two functions?  for example,

    x<- 1:100;
    plot(x, x^2, type="l");
    lines(x,0.5*x^2, type="l");
    # better
    plotwithfill(x, x^2, 0.5*x^2, color=c("yellow", "red");

where the first color is used if f(x)=x^2 > g(x)=0.5*x^2, and the second 
for the reverse.  Help appreciated.

Regards, / ivo

More information about the R-help mailing list