Thanks for the help, Carlos and Jean. What y'all sent worked beautifully. Ultimately I chose to use the rect() function. Below is my functional code (with a legend thrown in for good measure):
plot(x = c(1,numYears), y = c(200,300), main = c("Successional Trajectories for ",startState," Over Time"), xlab = "Time", ylab = "Vegetation Class", xlim = c(100,700), ylim = c(200,300), axes = FALSE, type="n") axis(1, at = c(100,200,300,400,500,600), labels = c("0","100","200","300","400","500")) rect(100, 199, 600, 205, border = NA, col=rgb(250,250,0,100,maxColorValue=255))#Yellow OA rect(100, 209, 600, 213, border = NA, col=rgb(250,125,0,100,maxColorValue=255))#Orange OW rect(100, 219, 600, 222, border = NA, col=rgb(180,100,0,100,maxColorValue=255))#Dk Orange OD rect(100, 229, 600, 235, border = NA, col=rgb(140,250,0,100,maxColorValue=255))#Lt Green DO rect(100, 239, 600, 248, border = NA, col=rgb(60,100,0,100,maxColorValue=255))#Dk Green DD rect(100, 259, 600, 266, border = NA, col=rgb(50,175,130,100,maxColorValue=255))#Teal DM rect(100, 269, 600, 272, border = NA, col=rgb(50,100,100,100,maxColorValue=255))#Slate DG rect(100, 279, 600, 287, border = NA, col=rgb(0,250,250,100,maxColorValue=255))#Lt Blue BM leg.txt <- c("BM","DG","DM","DD","DO","OD","OW","OA") legend("topright", legend = leg.txt, inset = 0, title = "Community Types", fill = c(rgb(0,250,250,100,maxColorValue=255), rgb(50,100,100,100,maxColorValue=255), rgb(50,175,130,100,maxColorValue=255), rgb(60,100,0,100,maxColorValue=255), rgb(140,250,0,100,maxColorValue=255), rgb(180,100,0,100,maxColorValue=255), rgb(250,125,0,100,maxColorValue=255), rgb(250,250,0,100,maxColorValue=255)), bty = "n") Thanks again for the help! - Gabe On Tue, Oct 11, 2011 at 11:39 AM, Jean V Adams <jvad...@usgs.gov> wrote: > > 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.