Hi, Is there any equivalent of type="n" when constructing barplots which will still construct the axes (plot=F, as it says doesn' plot anything at all). Alternatively I tried setting col="white" and border="white" but the border command does not seem to be operational. True?? Any other ideas? What I'm actually trying to do is construct vertical abline()'s _behind_ my plotted data. It seems to me that this requires axes construction then abline plotting then data plotting. Fine for plot() etc. but I don't seem to be able to manage it when barplotting. Is there some other way to do this that I'm missing? Cheers, Jeremy *************************************************************************** Jeremy Zachariah Butler BSc(hons) Department of Geography phone: 64 3 479 8788 University of Otago fax: 64 3 479 8706 Te Whare Wananga o Otago e-mail: butje612 at student.otago.ac.nz P.O. Box 56, Dunedin jerrytheshrub at hotmail.com New Zealand jeremybutler at paradise.net.nz ***************************************************************************
> -----Original Message----- > From: r-help-admin at stat.math.ethz.ch > [mailto:r-help-admin at stat.math.ethz.ch] On Behalf Of Jeremy Butler > Sent: Thursday, January 16, 2003 11:42 PM > To: r-help at stat.math.ethz.ch > Subject: [R] barplot plotting problem > > > Hi, > Is there any equivalent of type="n" when constructing > barplots which will still construct the axes (plot=F, as it > says doesn' plot anything at all). Alternatively I tried > setting col="white" and border="white" but the border command > does not seem to be operational. True?? > > Any other ideas? What I'm actually trying to do is construct > vertical abline()'s _behind_ my plotted data. It seems to me > that this requires axes construction then abline plotting > then data plotting. Fine for plot() etc. but I don't seem to > be able to manage it when barplotting. Is there some other > way to do this that I'm missing? Cheers, JeremyJeremy, There is not an equivalent in barplot to "type = n" in plot or "add TRUE" in boxplot. I will look into adding something like that in the barplot2() function in the gregmisc package. What you can do is something like: mp <- barplot(1:5) abline(v = mp) par(new = TRUE) barplot(1:5) What this does is to draw the initial barplot and store the bar midpoints in "mp". Using abline, you get vertical lines initially on top of the bars at their midpoints. Setting par(new = TRUE) tells R to not clear the plot window before the next call to barplot(). You then redraw the barplot, such that now the bars are over the vertical lines drawn by abline. You can then make any adjustments you need in the axes if you wish. Hope that helps. Regards, Marc
Jeremy Butler wrote:> Hi, > Is there any equivalent of type="n" when constructing barplots which > will still construct the axes (plot=F, as it says doesn' plot anything > at all). Alternatively I tried setting col="white" and border="white" > but the border command does not seem to be operational. True?? > > Any other ideas? What I'm actually trying to do is construct vertical > abline()'s _behind_ my plotted data. It seems to me that this requires > axes construction then abline plotting then data plotting. Fine for > plot() etc. but I don't seem to be able to manage it when barplotting. > Is there some other way to do this that I'm missing? >This may help.> xpos<-barplot(c(1.3,2.5,2,2,3.4)) > # there's probably a better way to clear the device... > plot(1:10,type="n",axes=F,xlab="",ylab="") > barplot(c(1.3,2.5,2,2,3.4),plot=F) > abline(v=xpos) > par(new=T) > xpos<-barplot(c(1.3,2.5,2,2,3.4)) > par(new=F)Jim