[R] barplot - change width of bar outline
Marc Schwartz
marc_schwartz at me.com
Fri Jun 3 06:25:22 CEST 2011
On Jun 2, 2011, at 10:54 PM, Rolf Turner wrote:
> 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
If you need the 'density' cross hatching, there is a workaround:
par(lwd = 3)
barplot(1:5, col = "white")
par(lwd = 1)
barplot(1:5, density = 10, add = TRUE)
If you don't need the cross hatching, just use the first two lines.
HTH,
Marc Schwartz
More information about the R-help
mailing list