Hi all, I have two vectors (columns) called "efinal" and "efinal 2". I want to plot them on the same plot and "draw" a shaded area beween the two lines using function polygon I have tried all but I don ?t understand the polygon area, can you help me with examples? plot(efinal,type="l",ylim=range(min(efinal2), max(efinal)),ylab="",main="plot") par(new=T) plot(efinal2,type="l",ylim=range(min(efinal2), max(efinal)),ylab="") The efinal are two temporal series I attach?
On 02.08.2012 14:33, Jose Narillos de Santos wrote:> Hi all, > > I have two vectors (columns) called "efinal" and "efinal 2". > > I want to plot them on the same plot and "draw" a shaded area beween the > two lines using function polygon > > I have tried all but I don ?t understand the polygon area, can you help me > with examples? > > plot(efinal,type="l",ylim=range(min(efinal2), > max(efinal)),ylab="",main="plot") > > par(new=T) > plot(efinal2,type="l",ylim=range(min(efinal2), max(efinal)),ylab="") > > The efinal are two temporal series I attach?Don't know, at least not attached to the message through R-help. I don't see what the problem is to construct a polygon() Just insert x and y values of both series in an appropriate order and connect them at the end. If you fail, provide fully reproducible code (we do not have efinal nor efinal 2 for now). Best, Uwe Ligges> > > ______________________________________________ > R-help at r-project.org mailing list > 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. >
Hi Jose, how about this example(polygon) I think the second one is pretty much what you want. cheers. Am 02.08.2012 14:33, schrieb Jose Narillos de Santos:> Hi all, > > I have two vectors (columns) called "efinal" and "efinal 2". > > I want to plot them on the same plot and "draw" a shaded area beween the > two lines using function polygon > > I have tried all but I don ?t understand the polygon area, can you help me > with examples? > > plot(efinal,type="l",ylim=range(min(efinal2), > max(efinal)),ylab="",main="plot") > > par(new=T) > plot(efinal2,type="l",ylim=range(min(efinal2), max(efinal)),ylab="") > > The efinal are two temporal series I attach? > > > > ______________________________________________ > R-help at r-project.org mailing list > 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. >-- Eik Vettorazzi Department of Medical Biometry and Epidemiology University Medical Center Hamburg-Eppendorf Martinistr. 52 20246 Hamburg T ++49/40/7410-58243 F ++49/40/7410-57790 -- Pflichtangaben gem?? Gesetz ?ber elektronische Handelsregister und Genossenschaftsregister sowie das Unternehmensregister (EHUG): Universit?tsklinikum Hamburg-Eppendorf; K?rperschaft des ?ffentlichen Rechts; Gerichtsstand: Hamburg Vorstandsmitglieder: Prof. Dr. Guido Sauter (Vertreter des Vorsitzenden), Dr. Alexander Kirstein, Joachim Pr?l?, Prof. Dr. Dr. Uwe Koch-Gromus
Hi I attach my function. No error message (it seems a line appears but nothing similar to examples(polygon)) 2012/8/2 Eik Vettorazzi <E.Vettorazzi at uke.de>> Hi Jose, > how about this > > example(polygon) > > I think the second one is pretty much what you want. > > cheers. > > Am 02.08.2012 14:33, schrieb Jose Narillos de Santos: > > Hi all, > > > > I have two vectors (columns) called "efinal" and "efinal 2". > > > > I want to plot them on the same plot and "draw" a shaded area beween the > > two lines using function polygon > > > > I have tried all but I don ?t understand the polygon area, can you help > me > > with examples? > > > > plot(efinal,type="l",ylim=range(min(efinal2), > > max(efinal)),ylab="",main="plot") > > > > par(new=T) > > plot(efinal2,type="l",ylim=range(min(efinal2), max(efinal)),ylab="") > > > > The efinal are two temporal series I attach? > > > > > > > > ______________________________________________ > > R-help at r-project.org mailing list > > 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. > > > > > -- > Eik Vettorazzi > > Department of Medical Biometry and Epidemiology > University Medical Center Hamburg-Eppendorf > > Martinistr. 52 > 20246 Hamburg > > T ++49/40/7410-58243 > F ++49/40/7410-57790 > > -- > Pflichtangaben gem?? Gesetz ?ber elektronische Handelsregister und > Genossenschaftsregister sowie das Unternehmensregister (EHUG): > > Universit?tsklinikum Hamburg-Eppendorf; K?rperschaft des ?ffentlichen > Rechts; Gerichtsstand: Hamburg > > Vorstandsmitglieder: Prof. Dr. Guido Sauter (Vertreter des Vorsitzenden), > Dr. Alexander Kirstein, Joachim Pr?l?, Prof. Dr. Dr. Uwe Koch-Gromus > >
> The efinal are two temporal series I attach?Not attached. R-help typically strips out any attachment to prevent malware being spread. The best way to supply sample date is to use the dput() command. See ?dput for details but basically just say dput(myfile) and copy the results into your email. Readers can directly paste the file into their R console and see exactly what your data is. John Kane Kingston ON Canada ____________________________________________________________ FREE ONLINE PHOTOSHARING - Share your photos online with your friends and family! Visit http://www.inbox.com/photosharing to find out more!
Data came through fine. I can never plot a polygon without help but I think you have a data problem. Try this: efinal == efinal2 John Kane Kingston ON Canada -----Original Message----- From: narillosdesantos at gmail.com Sent: Thu, 2 Aug 2012 16:55:23 +0200 To: jrkrideau at inbox.com Subject: Re: [R] Polygon shaded area Hi many thanks, That is my data.> dput(efinal)c(0.9525, 0.89785, 0.8931, 0.9308, 0.89335, 0.8729, 0.8521, 0.8556, 0.88135, 0.9093, 0.89375, 0.91155, 0.8881, 0.86655, 0.8927, 0.8898, 0.8703, 0.84863, 0.81745, 0.8349, 0.8248, 0.85995, 0.8686, 0.83765, 0.86075, 0.8609, 0.8528, 0.8837, 0.8917, 0.8671, 0.87205, 0.90255, 0.87485, 0.8856, 0.86665, 0.8731, 0.8558, 0.8353, 0.8557130916294, 0.861971323468187, 0.865900731747475, 0.868624652247, 0.870578199623624, 0.871984527163596, 0.872976198154798, 0.873639584912775, 0.8740346818528, 0.87420517054346, 0.874184027040643, 0.873996870459551)> dput(efinal2)c(0.9525, 0.89785, 0.8931, 0.9308, 0.89335, 0.8729, 0.8521, 0.8556, 0.88135, 0.9093, 0.89375, 0.91155, 0.8881, 0.86655, 0.8927, 0.8898, 0.8703, 0.84863, 0.81745, 0.8349, 0.8248, 0.85995, 0.8686, 0.83765, 0.86075, 0.8609, 0.8528, 0.8837, 0.8917, 0.8671, 0.87205, 0.90255, 0.87485, 0.8856, 0.86665, 0.8731, 0.8558, 0.8353, 0.8073853773588, 0.793625614508213, 0.782194675217125, 0.771969223705801, 0.762514145317377, 0.753606286765605, 0.745113084762604, 0.736948166992827, 0.729051539041001, 0.721379519338542, 0.713899131829559, 0.706584757398851) 2012/8/2 John Kane <[1]jrkrideau at inbox.com> > The efinal are two temporal series I attach? Not attached. R-help typically strips out any attachment to prevent malware being spread. The best way to supply sample date is to use the dput() command. See ?dput for details but basically just say dput(myfile) and copy the results into your email. Readers can directly paste the file into their R console and see exactly what your data is. John Kane Kingston ON Canada ____________________________________________________________ FREE ONLINE PHOTOSHARING - Share your photos online with your friends and family! Visit [2]http://www.inbox.com/photosharing to find out more! _________________________________________________________________ [3]3D Marine Aquarium Screensaver Preview Free 3D Marine Aquarium Screensaver Watch dolphins, sharks & orcas on your desktop! Check it out at [4]www.inbox.com/marineaquarium References 1. mailto:jrkrideau at inbox.com 2. http://www.inbox.com/photosharing 3. http://www.inbox.com/marineaquarium 4. http://www.inbox.com/marineaquarium
Hi Jose, this should work (but I think you need a deeper understanding, what plot(efinal) does, see ?plot): plot(efinal,ylim=range(c(efinal,efinal2)),type="n",ylab="") xv<-seq_along(efinal) polygon(c(xv,rev(xv)),c(efinal,rev(efinal2)),col="red") cheers Am 02.08.2012 16:36, schrieb Jose Narillos de Santos:> Hi I attach my function. No error message (it seems a line appears but > nothing similar to examples(polygon)) > > > > 2012/8/2 Eik Vettorazzi <E.Vettorazzi at uke.de <mailto:E.Vettorazzi at uke.de>> > > Hi Jose, > how about this > > example(polygon) > > I think the second one is pretty much what you want. > > cheers. > > Am 02.08.2012 14:33, schrieb Jose Narillos de Santos: > > Hi all, > > > > I have two vectors (columns) called "efinal" and "efinal 2". > > > > I want to plot them on the same plot and "draw" a shaded area > beween the > > two lines using function polygon > > > > I have tried all but I don ?t understand the polygon area, can you > help me > > with examples? > > > > plot(efinal,type="l",ylim=range(min(efinal2), > > max(efinal)),ylab="",main="plot") > > > > par(new=T) > > plot(efinal2,type="l",ylim=range(min(efinal2), max(efinal)),ylab="") > > > > The efinal are two temporal series I attach? > > > > > > > > ______________________________________________ > > R-help at r-project.org <mailto:R-help at r-project.org> mailing list > > 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. > > > > > -- > Eik Vettorazzi > > Department of Medical Biometry and Epidemiology > University Medical Center Hamburg-Eppendorf > > Martinistr. 52 > 20246 Hamburg > > T ++49/40/7410-58243 <tel:%2B%2B49%2F40%2F7410-58243> > F ++49/40/7410-57790 <tel:%2B%2B49%2F40%2F7410-57790> > > -- > Pflichtangaben gem?? Gesetz ?ber elektronische Handelsregister und > Genossenschaftsregister sowie das Unternehmensregister (EHUG): > > Universit?tsklinikum Hamburg-Eppendorf; K?rperschaft des > ?ffentlichen Rechts; Gerichtsstand: Hamburg > > Vorstandsmitglieder: Prof. Dr. Guido Sauter (Vertreter des > Vorsitzenden), Dr. Alexander Kirstein, Joachim Pr?l?, Prof. Dr. Dr. > Uwe Koch-Gromus > >-- Eik Vettorazzi Department of Medical Biometry and Epidemiology University Medical Center Hamburg-Eppendorf Martinistr. 52 20246 Hamburg T ++49/40/7410-58243 F ++49/40/7410-57790 -- Pflichtangaben gem?? Gesetz ?ber elektronische Handelsregister und Genossenschaftsregister sowie das Unternehmensregister (EHUG): Universit?tsklinikum Hamburg-Eppendorf; K?rperschaft des ?ffentlichen Rechts; Gerichtsstand: Hamburg Vorstandsmitglieder: Prof. Dr. Guido Sauter (Vertreter des Vorsitzenden), Dr. Alexander Kirstein, Joachim Pr?l?, Prof. Dr. Dr. Uwe Koch-Gromus