error_bar: error bar

Description Usage Arguments Examples

View source: R/plots.R

Description

add a single error bar to a plot

Usage

1
error_bar(x, y, ll, ul, width)

Arguments

x

x coordinate

y

y coordinate - a point gets drawn there

ll

lower limit - position of the lower whisker

ul

upper limit - position of the upper whisker

width

width of the whisker ends

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
#single:
plot(NULL, xlim = c(0, 2), ylim = c(0, 5))
error_bar(1, 2.5, 1, 4.5, 1)

#multiple:
percentile <- do.call('rbind', lapply(list(c(1:4), c(2:5), c(3:6)), quantile))
plot(NULL, xlim = c(0, 4), ylim = c(0, 7))
lapply(seq_len(nrow(percentile)),
       FUN = function(x) error_bar(x,
                                   percentile[x, 3],
                                   percentile[x, 2],
                                   percentile[x, 4],
                                   width = 0.5))

konradmayer/trlboku documentation built on July 3, 2020, 9:49 p.m.