[R] How to plot shades between curves?

Jackson Rodrigues jacksonmrodrigues at gmail.com
Sun Oct 18 16:15:20 CEST 2015


Dear all,

I have to compare several curves that range through different scales (x
axis) along the same time, so to make them comparable I brought all of them
to the same scale (x axis) and obviously kept the age axis (y axis) for all
of them.
As result, some variations (wiggles) simply disappeared (Figure on link
below, line Capa.diss) making impossible any interpretation. To deal with
such of problem, I plot the curve as it has to be in large scale (line
Capa.diss) and added a the same curve again on a secondary axis, but
exaggerating its values by a subjective factor of 0.7 (Capa.diss2).
Further, I want to fill the gap between both curves with some color.

Figure available on:
https://www.dropbox.com/s/dtcgk167mh9xykj/12120156_533366843482278_6929357065463452649_o.jpg?dl=0

My idea in doing it is: I have a plot in which the wiggles are "invisible",
to highlight these wiggles I projected a shadded curve of exaggerated data.

My question is: How to plot shades between curves?


Thank you all

Jackson Rodrigues

My codes are:

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")


Date used:

Capa.diss<-c(0.7261102, 0.6655960, 0.5638357,0.8585834,0.6964527,0.8434504,
0.7106749,0.5981460,0.5747585,0.7347864,0.8012803,0.6826862,0.4949845,
0.5466870,0.5417343
,0.4774860,0.4814479,0.5254794,0.6236299,0.6575862,0.7047694,0.5550153,0.4499349,0.5939971,0.4138955,0.3659061,0.3126497,0.2476329,0.2503446,0.2686042,0.3036808,0.2747602,0.4221727,0.3935815,0.3942621,0.5821026,0.2251284,0.2670861,0.3580937,0.4239509,0.4010682,0.4104427,0.3666264,0.2555372,0.2995469,0.3985690,0.4304724,0.4136308,0.3525836,0.3898816,0.3517483,0.2924678,0.4807643,0.4471870,0.3694882,0.3970183,0.4827425,0.4766994,0.3391238,0.4153885,0.5502231,0.5330776,0.5867776,0.5195776,0.4882179,0.5298611,0.4626142)

Capa.diss.age<-c(2,152,302,452,602,752,902,1052,1202,1352,1502,1652,1802,1952,2102,2252,2402,2552,2702,2852,3002,3152,3302,3452,3602,3752,3902,4052,4202,4352,4502,4652,4802,4952,5102,5252,5402,5552,5702,5852,6002,6152,6302,6452,6602,6752,6902,7052,7202,7352,7502,7652,7802,7952,8102,8252,8402,8552,8702,8852,9002,9152,9302,9452,9602,9752,9902)

	[[alternative HTML version deleted]]



More information about the R-help mailing list