[R] Changing border width in barplot ?

Marc Schwartz marc_schwartz at me.com
Tue Dec 8 21:38:44 CET 2009


On Dec 8, 2009, at 2:26 PM, Tal Galili wrote:

> Is it possible?
> I was hoping to find something like:
> lwd
> for the different bars in the barplot but couldn't find it.
> Does it exist ?
>
> Thanks,
> Tal



barplot() calls rect() via a wrapper function internally to draw the  
rectangles. rect() uses par("lwd") to define the line widths by default:

   par(mfrow = c(2, 1))

   barplot(1:5)

   par(lwd = 3)

   barplot(1:5)


If you wanted to define the widths of the lines on a per bar basis,  
you would need to manually create the bars using rect() directly,  
since there is no other way that I can see to pass a vector of line  
widths as the code is presently implemented.

You might want to look at the barchart() function in lattice to see if  
there is more functionality there.

HTH,

Marc Schwartz




More information about the R-help mailing list