[R] Drawing a rectangle around a barplot()
B.Rowlingson at lancaster.ac.uk
Thu Dec 2 12:07:03 CET 2004
michael watson (IAH-C) wrote:
> I can't use box() as I don't
> want to draw a box round my entire plot, I just want to draw a box as
> the background to certain subsets of the bars.
One idea. Edit the barplot.default function so it doesnt call plot.new.
myBarplot = barplot.default
then edit the myBarplot function. Add an extra parameter to the
argument list 'add', and make it False by default:
cex.names = par("cex.axis"), inside = TRUE, plot = TRUE,
axis.lty = 0, add=F, ...)
then find plot.new and wrap it in a condition:
tN <- table(Ni <- rpois(100, lambda=5))
- this puts the rectangle on top of the bars, which you dont want, so
you call myBarplot with add=T so that plot.new isnt called and the
barplot appears over the rectangle:
works for me, if I understand your problem correctly!
More information about the R-help