RCEIM (version 0.2)

overPlotErrorPolygon: Overplot an error polygon

Description

A simple function to overplot an error polygon around a curve. Note that the error is considered as symmetric, and exclusively on y. The polygon will be created from the coordinate tuples $(x, (y - err_y))$ and $(x, (y + err_y))$.

Usage

overPlotErrorPolygon(x, y, err_y, col = "grey", logPlot = FALSE, ...)

Arguments

x
A vector containing the x coordinate of the data.
y
A vector containing the y coordinate of the data.
err_y
A vector containing the error in y.
col
The color that will be used for filling the polygon.
logPlot
A boolean indicating if the plot is in logscale.
...
Further arguments to be passed to polygon().

Value

A polygon is overplotted in the active graphics device.

Examples

Run this code
# Shows a simple random curve and overplots a randomly created error bar.
dev.new()
xx <- 1:10
yy <- (1:10)/5 + 4 + (runif(10)-0.5)/0.5*2
plot(xx, yy, type="l", xlab="x", ylab="y", ylim=c(0,10))
err_yy <- 1.5 + (runif(10)-0.5)/0.5
overPlotErrorPolygon(xx,yy,err_yy, col=rgb(0,0,1,0.3), border=NA)

Run the code above in your browser using DataLab