[R] barplot - change width of bar outline

Rolf Turner rolf.turner at xtra.co.nz
Fri Jun 3 05:54:17 CEST 2011


On 03/06/11 10:26, CAB wrote:
> Dear R users
> I am modifying a column chart which I have created in R using barplot to
> make it clearer. I have been able to change the settings to increase the
> width of the axes lines and the text size but I cannot find the code to
> change the width of the lines which create the bars/columns themselves. Can
> anyone point me in the right direction please?

As the code currently stands, it would appear that you *can't* change
the widths of the lines which create the bars.

However, it wouldn't be too hard to hack the code to make this 
possible.   One
thing that makes it slightly tricky is that the code allows for 
cross-hatching
of the bars, and that is effected by the rect() function.  The lwd argument
to rect() has an impact upon both the perimeter of the rectangle and
the cross-hatch lines.  Presumably you don't want to increase the line width
of the latter.  Hence you'd have to make two calls to rect() --- one to
draw the perimeter with the line width increased, and no cross-hatching,
and then again with the line width as usual and with the specification 
of the
cross-hatching included.

The code for barplot.default() is all in raw R (no mucking around with
calls to .Internal() !!!) and is pretty straightforward, so the hack won't
be too hard to implement.

Good luck.

     cheers,

         Rolf Turner



More information about the R-help mailing list