AddIntervals: Add Interval Symbols to Plot

Description Usage Arguments Details Value Author(s) Examples

View source: R/AddIntervals.R

Description

Add interval symbols (also known as error bars) to plots.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
AddIntervals(
  x,
  y0,
  y1,
  hin = NULL,
  col = "black",
  lty = 1,
  lwd = 0.7,
  cex = 1,
  xpd = FALSE,
  ...,
  nondetects = NULL
)

Arguments

x

'numeric' or 'Date' vector. x coordinate of interval symbols.

y0

'numeric' vector. y coordinate of points from which to draw.

y1

'numeric' vector. y coordinate of points to which to draw.

hin

'numeric' number. Horizontal length of an interval head, in inches.

col, lty, lwd, cex, xpd

graphical parameters; see par for details. NA values in col cause the interval to be omitted.

...

Additional graphical parameters to the points function.

nondetects

'list'. Overrides graphical parameters used for left- and right-censored data. Passed arguments include col, lty, and lwd.

Details

For each observation i, the data type is identified using (y0[i], Inf) for right-censored, y0[i] = y1[i] for exact, and (-Inf, y1[i]) for left-censored, and (y0[i], y1[i]) for interval-censored. Where infinity may be represented with either Inf or NA.

Value

Invisible NULL

Author(s)

J.C. Fisher, U.S. Geological Survey, Idaho Water Science Center

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
set.seed(1)
x <- stats::runif(12)
y <- stats::rnorm(12)
plot(x, y)
dy <- sort.int(y) / 5
AddIntervals(x, y - dy, y + dy, col = "red", xpd = TRUE)

n <- 50
x <- sort.int(stats::runif(n, max = 100))
y1 <- y0 <- stats::runif(n, max = 100)
y1[sample.int(n, 5)] <- stats::runif(5, max = 100)
y0[sample.int(n, 5)] <- -Inf
y1[sample.int(n, 5)] <-  Inf
ylim <- range(pretty(c(y0, y1)))
plot(NA, xlim = range(x), ylim = ylim, xlab = "x", ylab = "y")
AddIntervals(x, y0, y1, col = "blue", xpd = TRUE,
             nondetects = list("col" = "red", "lty" = 2))
print(cbind(x, y0, y1))

inlmisc documentation built on Jan. 25, 2022, 1:14 a.m.