magerr | R Documentation |
A function to add x and y error bars to plots. Low and high error bars can be generated.
magerr(x, y, xlo, ylo, xhi = xlo, yhi = ylo, corxy, length = 0.02,
col = 'black', fill = FALSE, poly = FALSE, ...)
x |
Numeric vector; x location of data. |
y |
Numeric vector; y location of data. |
xlo |
Numeric vector; error on the low side for x values. This can be positive or negative- the absolute vaue is used. If length 1, then will be repeated length(x) times. |
ylo |
Numeric vector; error on the low side for y values. This can be positive or negative- the absolute vaue is used. If length 1, then will be repeated length(x) times. |
xhi |
Numeric vector; error on the high side for x values. This can be positive or negative- the absolute vaue is used. By default this will inherit the xlo value. If length 1, then will be repeated length(x) times. |
yhi |
Numeric vector; error on the high side for y values. This can be positive or negative- the absolute vaue is used. By default this will inherit the ylo value. If length 1, then will be repeated length(x) times. |
corxy |
Numeric vector; if this parameter exists then error ellipses will be drawn instead of error bars. It takes the value of the sigma_x sigma_y correlation, i.e. corxy=covxy/(xlo*ylo). If length 1, then will be repeated length(x) times. |
length |
Numeric vector; length of error bar ends. If length 1, then will be repeated length(x) times. |
col |
Either the colour of the error bars or the outline colour of the error ellipses. If length 1, then will be repeated length(x) times. |
fill |
Logical; if TRUE then the error ellipses will be filled, if FALSE then only the border will be drawn. |
poly |
Logical; is FALSE then error bars or ellipses will be drawn, if TRUE then approximate error polygon will be shown instead. |
... |
Further arguments to be passed to the |
Note that with poly=TRUE the x values are used igoring any error terms, and the point value y errors are used to define the limits of the polygon, with straight lines joining the points. The col option is used to fill the polygon with a colour (so the default black is probably not a great choice). The polygon
function takes the argument border (parsed by dots from the magerr
function) to colour the outer lines, so for a more subtle error polygon you might want to use col=lightgrey, border=NA, where NA means no outer border lines are drawn.
Called for the side effect of plotting error bars.
Aaron Robotham
magplot
, magaxis
, maglab
, magmap
, magrun
, arrows
, draw.ellipse
, polygon
# Basic x and y errors added to plot
temp=cbind(x=runif(10),y=runif(10),xerr=runif(10,0.05,0.2),yerr=runif(10,0.1,0.3),
corxy=runif(10,-1,1))
magplot(temp[,1:2])
magerr(x=temp[,1],y=temp[,2],xlo=temp[,3],ylo=temp[,4])
# Example of errors on plots wityh log axes
magplot(temp[,1:2],log='xy')
magerr(x=temp[,1],y=temp[,2],xlo=temp[,3],ylo=temp[,4])
#Example of error ellipses
magplot(temp[,1:2])
magerr(x=temp[,1],y=temp[,2],xlo=temp[,3],ylo=temp[,4])
magerr(x=temp[,1],y=temp[,2],xlo=temp[,3],ylo=temp[,4],corxy=temp[,5])
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.