Hello, I would like to draw vertical yellow bands in my graph, but could not find how to do that in the documentation. I set up a page to show what I would like to achieve: http://rstudent.blogg.de/eintrag.php?id=1 (the first picture was manually colored with the Gimp). Any help would be welcome... All the best, Delfina _________________________________________________________________ [[replacing trailing spam]]
del pes wrote:> Hello, > > I would like to draw vertical yellow bands in my graph, but could not find how to do that in the documentation. > > I set up a page to show what I would like to achieve: http://rstudent.blogg.de/eintrag.php?id=1 (the first picture was manually colored with the Gimp). >Hi Delfina, For a one-off, I would use the rect function. fakedat<-0.985+rnorm(80)/100 plot(fakedat,main="My Striped Plot",type="n") rect(seq(5,75,by=10),par("usr")[3],seq(10,80,by=10),par("usr")[4], col="yellow") points(fakedat,type="b") abline(h=0.98) Jim
There is an example using classic graphics here: http://www.mayin.org/ajayshah/KB/R/html/g5.html and one using lattice graphics here: library(zoo) ?xyplot.zoo On 8/23/07, del pes <cgdelnet at hotmail.com> wrote:> > Hello, > > I would like to draw vertical yellow bands in my graph, but could not find how to do that in the documentation. > > I set up a page to show what I would like to achieve: http://rstudent.blogg.de/eintrag.php?id=1 (the first picture was manually colored with the Gimp). > > Any help would be welcome... > > All the best, > > Delfina > _________________________________________________________________ > [[replacing trailing spam]] > > ______________________________________________ > R-help at stat.math.ethz.ch 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. >
?rect Something like this should work but I did not take the time to get the rectangles to fit properly. aa <- rnorm(25) yl <- -1.5 yh <- 2.2 xleft <- c(4, 9, 15 ,20) xright <- xleft + 3 plot(aa, ylim= c(yl,yh), type="n") rect(xleft, yl, xright,yh, col="yellow") points(aa, col="red") --- del pes <cgdelnet at hotmail.com> wrote:> > Hello, > > I would like to draw vertical yellow bands in my > graph, but could not find how to do that in the > documentation. > > I set up a page to show what I would like to > achieve: http://rstudent.blogg.de/eintrag.php?id=1 > (the first picture was manually colored with the > Gimp). > > Any help would be welcome... > > All the best, > > Delfina >_________________________________________________________________> [[replacing trailing spam]] > > ______________________________________________ > R-help at stat.math.ethz.ch 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. >
Thank you all for your answers, the rect function with seq (to do regular
rectangles) worked perfectly
fakedat<-0.985+rnorm(80)/100
plot(fakedat,main="My Striped Plot",type="n")
rect(seq(5,75,by=10),par("usr")[3],seq(10,80,by=10),par("usr")[4],
col="yellow")
points(fakedat,type="b")
abline(h=0.98)
Very nice presentation coming out in no time, R is the best!
Delfina
----------------------------------------> Date: Fri, 24 Aug 2007 20:26:53 +1000
> From: jim at bitwrit.com.au
> To: cgdelnet at hotmail.com
> CC: r-help at stat.math.ethz.ch
> Subject: Re: [R] How to shade vertical bands in a graph?
> 
> del pes wrote:
> > Hello,
> > 
> > I would like to draw vertical yellow bands in my graph, but could not
find how to do that in the documentation.
> > 
> > I set up a page to show what I would like to achieve:
http://rstudent.blogg.de/eintrag.php?id=1 (the first picture was manually
colored with the Gimp).
> > 
> Hi Delfina,
> For a one-off, I would use the rect function.
> 
> fakedat<-0.985+rnorm(80)/100
> plot(fakedat,main="My Striped Plot",type="n")
>
rect(seq(5,75,by=10),par("usr")[3],seq(10,80,by=10),par("usr")[4],
>   col="yellow")
> points(fakedat,type="b")
> abline(h=0.98)
> 
> Jim
_________________________________________________________________
[[replacing trailing spam]]