overPlotErrorPolygon function

Overplot an error polygon

Overplot an error polygon

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,(yerry))(x, (y - err_y)) and (x,(y+erry))(x, (y + err_y)).

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().

Returns

A polygon is overplotted in the active graphics device.

Author(s)

Alberto Krone-Martins

Examples

# 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)
  • Maintainer: Alberto Krone-Martins
  • License: GPL (>= 2)
  • Last published: 2017-04-03

Useful links