[R] How to plot shades between curves?

Jim Lemon drjimlemon at gmail.com
Mon Oct 19 00:31:35 CEST 2015


Hi Jackson,
>From your description, I think you are trying to illustrate the deviation
of Capa.diss, so I will offer an entirely different method. If you do want
the primary line on the left of the plot with a big space on the right,
presumably to add more stuff there, try this:

plot(Capa.diss.mean + 10 * (Capa.diss-Capa.diss.mean),Capa.diss.age,
 type="l",col="gray",xlim=c(-1,30),xlab="Capa.diss")
lines(Capa.diss,Capa.diss.age)

This exaggerates the deviation of Capa.diss from its mean by a factor of 10
in the first gray line, then plots the "real" deviations over it as a black
line. Another possibility is that you want to decompose Capa.diss into low
and high frequency deviations (i.e. long term trend and transient
variation). That would involve a similar plotting technique.

Jim


On Mon, Oct 19, 2015 at 1:29 AM, Benno Pütz <puetz at psych.mpg.de> wrote:

>
> >
> > 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
> ______________________________________________
> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
> 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.
>

	[[alternative HTML version deleted]]



More information about the R-help mailing list