errorbars: add asymertric error bars to existing scatter plot

Description Usage Arguments Details Examples

Description

errorbars(mat,bplot=NULL,wid=max(explan/100),lty=1,brk=0,...)

Usage

1
errorbars(mat, bplot = NULL, wid = NULL, lty = 1, brk = 0, ...)

Arguments

mat

a matrix or data frame of values to specify error bars. First column should be either x-axis values or (if adding to a barplot) y-axis values of bar centres (usually means). Second column should be y-axis values of bar centres or (if barplot) size of error bar. Third column should be size of error bar. If an additional column is given (third column for barplot, fourth column otherwise), these are size of bar from centre to upper limit and the previous column used for sizes of bar from centre to lower limit.

bplot

the name of an existing barplot (if adding error bars to barplot)

wid

width of bar ends

brk

size of break in vertical bar around data point

...

further graphical parameters to pass to lines() function

Details

Add error bars to existing plots, either barplot or some other type, most likely scatter. The values are supplied as a matrix (or data frame) with n columns (or n-1) columns for a barplot where the x-axis values are not supplied but taken from the barplot. Columns must include the y-axis mid values (usually the mean values) and a size of error bar. If asymmetrical bars are required, there will be an additional column of the matrix containing these.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
# use the library dplyr
Rock = rock %>% group_by(perm) %>%
 summarise(Mn = mean(shape), CI95 = sd(shape)/length(shape)^2*2) %>%
 as.matrix()
plot(Mn ~ perm, Rock, pch = 19, cex = 0.6, ylim=c(.12,.4))
bars(Rock, brk = 0.008)
# Barplot
MatBP = InsectSprays %>% group_by(spray) %>%
 summarise(Mn = mean(count), SD = sd(count)) %>% as.data.frame()
BP = barplot(MatBP[,2], ylim=c(0,24))
bars(MatBP[,-1], bplot=BP, wid=0.1, brk = 0.5)

helophilus/ColsTools documentation built on May 30, 2019, 4:03 p.m.