[R] How to plot shades between curves?

Benno Pütz puetz at psych.mpg.de
Sun Oct 18 16:29:39 CEST 2015


> 
> plot(Capa.diss,Capa.diss.age,ylim =
> rev((range)(Capa.diss.age=c(min(Capa.diss.age),
> 10500))),xlim=(c(0,30)),type="l")
> Capa.diss2<-Capa.diss*0.7
> par(new=TRUE)
> plot(Capa.diss2, Capa.diss.age, col='black',type="l",ylim =
> rev((range)(Capa.diss.age=c(min(Capa.diss.age), 10500))),
> xlim=(c(0,1)),xaxt="n",yaxt="n",xlab="",ylab="")
> 
> The following lline is the one I trying to use to fill the gap, but it is
> not working.
> polygon(c(Capa.diss.age,rev(Capa.diss.age)),c(Capa.diss2,rev(Capa.diss)),col="grey")
> 
Comparing this line with the code above I get the impression that you have the wrong order in your coordinates (x and y switched) - you plot way outside your [xy]lims and thus won’t see anything. 
Otherwise your approach seems OK

Benno


More information about the R-help mailing list