[R] fill between lines
andy_liaw at merck.com
Mon Apr 19 20:35:49 CEST 2004
Nothing easily that I can think of. You need to plot each `piece'
separately using polygon(). I.e.,
1. Find the `pieces'.
2. Determine the color the piece should be in.
3. Draw the piece with polygon().
Step 1 above is probably the trickiest part, but quite doable, I think.
> From: ivo welch
> 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
> R-help at stat.math.ethz.ch mailing list
> PLEASE do read the posting guide!
More information about the R-help