Skip to content
Prev 315874 / 398506 Next

change confidence interval line length in barplot2 (plotrix package)

On Jan 22, 2013, at 2:41 PM, Martin Batholdy <batholdy at googlemail.com> wrote:

            
barplot2() in gplots uses a hard coded width for the CI's, which is 50% of the bar width, so it is a consistent proportion.

You could hack the code or simply use base graphics barplot() along with either ?segments or perhaps more easily, ?arrows, which would give you more flexibility.

Compare:

mp <- barplot(1:5)
arrows(mp, 1:5 + 0.5, mp, 1:5 - 0.5, code = 3, angle = 90, length = 0.1)

with:

mp <- barplot(1:5)
arrows(mp, 1:5 + 0.5, mp, 1:5 - 0.5, code = 3, angle = 90, length = 0.25)

where the 'length' argument to arrows() defines the width of the upper and lower boundary lines.

There are a fair number of other functions around that can add CI's to plots as well and a search of the archives should bear fruit.

Regards,

Marc Schwartz