Carlos Ortega wrote on 10/11/2011 11:30:46 AM:
> 
> Hi,
> 
> Yes, one way to do that is by using function polygon().
> 
> Regards,
> Carlos Ortega
> www.qualityexcellence.es
> 
> 2011/10/11 Gabriel Yospin <yosp...@gmail.com>
> 
> > Hi R-Help -
> >
> > If I make a plot:
> >
> > numYears = 500
> > plot(x = c(1,numYears), y = c(200,300), xlab = "Time", ylab = 
"Vegetation
> > Class", xlim = c(100,600), ylim = c(200,300), type="n")
> >
> > Is there a way to make different parts of the background for the plot
> > different colors?
> >
> > For example, I'd like to have the background color col = 
(250,250,0,50) for
> > y = c(200,204), and col = (250,125,0,50) for y = c(210,212).
> >
> > Any suggestions?
> >
> > Thanks in advance for the help,
> >
> > Gabe
> > --
> > Gabriel I. Yospin
> >
> > Institute of Ecology and Evolution
> > Bridgham Lab
> > University of Oregon
> > Eugene, OR 97403-5289
> >
> > Ph: 541 346 1549
> > Fax: 541 346 2364


For example:

plot(1, 1, xlab="Time", ylab="Vegetation Class", 
        xlim=c(100, 600), ylim=c(200, 300), type="n")
xrange <- par("usr")[1:2]
polygon(c(xrange, rev(xrange)), c(200, 200, 204, 204), 
        col=rgb(250, 250, 0, 50, maxColorValue=255), border=NA)
polygon(c(xrange, rev(xrange)), c(210, 210, 212, 212), 
        col=rgb(250, 125, 0, 50, maxColorValue=255), border=NA)
points(10*(20:30), 10*(20:30))

Jean
        [[alternative HTML version deleted]]

______________________________________________
R-help@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.

Reply via email to