1 |
x |
|
y |
|
uiw |
|
liw |
|
aui |
|
ali |
|
err |
|
ylim |
|
sfrac |
|
gap |
|
add |
|
col |
|
lwd |
|
slty |
|
xlab |
|
ylab |
|
... |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 | ##---- Should be DIRECTLY executable !! ----
##-- ==> Define data, use random,
##-- or do help(data=index) for the standard data sets.
## The function is currently defined as
function (x, y = NULL, uiw = NULL, liw = uiw, aui = NULL, ali = aui,
err = "y", ylim = NULL, sfrac = 0.01, gap = 0, add = FALSE,
col = par("col"), lwd = par("lwd"), slty = par("lty"), xlab = NULL,
ylab = NULL, ...)
{
if (is.list(x)) {
y <- x$y
x <- x$x
}
if (is.null(y)) {
if (is.null(x))
stop("both x and y NULL")
y <- as.numeric(x)
x <- seq(along = x)
}
if (missing(xlab))
xlab <- deparse(substitute(x))
if (missing(ylab))
ylab <- deparse(substitute(y))
if (missing(uiw)) {
ui <- aui
li <- ali
}
else {
if (err == "y")
z <- y
else z <- x
if (is.null(uiw))
stop("Argument uiw, the width of the interval, must be specified")
ui <- z + uiw
li <- z - liw
}
if (is.null(ylim))
ylim <- range(c(y, ui, li), na.rm = TRUE)
if (add) {
points(x, y, col = col, lwd = lwd, ...)
}
else {
plot(x, y, ylim = ylim, col = col, lwd = lwd, xlab = xlab,
ylab = ylab, ...)
}
if (gap == TRUE)
gap <- 0.01
ul <- c(li, ui)
if (err == "y") {
gap <- rep(gap, length(x)) * diff(par("usr")[3:4])
smidge <- par("fin")[1] * sfrac
arrows(x, li, x, pmax(y - gap, li), col = col, lwd = lwd,
lty = slty, angle = 90, length = smidge, code = 1)
arrows(x, ui, x, pmin(y + gap, ui), col = col, lwd = lwd,
lty = slty, angle = 90, length = smidge, code = 1)
}
else if (err == "x") {
gap <- rep(gap, length(x)) * diff(par("usr")[1:2])
smidge <- par("fin")[2] * sfrac
arrows(li, y, pmax(x - gap, li), y, col = col, lwd = lwd,
lty = slty, angle = 90, length = smidge, code = 1)
arrows(ui, y, pmin(x + gap, ui), y, col = col, lwd = lwd,
lty = slty, angle = 90, length = smidge, code = 1)
}
invisible(list(x = x, y = y))
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.