Learn R Programming

pracma (version 1.5.8)

errorbar: Plot Error Bars

Description

Draws symmetric error bars in x- and/or y-direction.

Usage

errorbar(x, y, xerr = NULL, yerr = NULL,
         bar.col = "red", bar.len = 0.01,
         grid = TRUE, with = TRUE, add = FALSE, ...)

Arguments

x, y
x-, y-coordinates
xerr, yerr
length of the error bars, relative to the x-, y-values.
bar.col
color of the error bars; default: red
bar.len
length of the cross bars orthogonal to the error bars; default: 0.01.
grid
logical; should the grid be plotted?; default: true
with
logical; whether to end the error bars with small cross bars.
add
logical; should the error bars be added to an existing plot?; default: false.
...
additional plotting parameters that will be passed to the plot function.

Value

  • Generates a plot, no return value.

Details

errorbar plots y versus x with symmetric error bars, with a length determined by xerr resp. yerr in x- and/or y-direction. If xerr or yerr is NULL error bars in this direction will not be drawn.

A future version will allow to draw unsymmetric error bars by specifying upper and lower limits when xerr or yerr is a matrix of size (2 x length(x)).

See Also

plotrix::plotCI, Hmisc::errbar

Examples

Run this code
x <- seq(0, 2*pi, length.out = 20)
y <- sin(x)
xe <- 0.1
ye <- 0.1 * y
errorbar(x, y, xe, ye, type = "l", with = FALSE)

cnt <- round(100*randn(20, 3))
y <- apply(cnt, 1, mean)
e <- apply(cnt, 1, sd)
errorbar(1:20, y, yerr = e, bar.col = "blue")

Run the code above in your browser using DataLab