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]]
> > 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
Hi, Thanks for the reproducible example! (Don't forget to make your email client send text-only messages, not html, when sending to this list). Would log scale work for you? 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) plot(Capa.diss,Capa.diss.age, ylim = c(0,10500), xlim = pmax(range(Capa.diss), c(0.1, 30)), type="l", log = 'x') Note that pmax() is selecting the maximum of each element in the two input vectors - you might want something different Cheers, Ben On Oct 18, 2015, at 10:15 AM, Jackson Rodrigues <jacksonmrodrigues at gmail.com> wrote:> 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]] > > ______________________________________________ > 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.Ben Tupper Bigelow Laboratory for Ocean Sciences 60 Bigelow Drive, P.O. Box 380 East Boothbay, Maine 04544 http://www.bigelow.org
Hi Jackson,>From your description, I think you are trying to illustrate the deviationof 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]]