-
Notifications
You must be signed in to change notification settings - Fork 97
/
Copy pathplot.ordisurf.R
37 lines (37 loc) · 1.27 KB
/
plot.ordisurf.R
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
`plot.ordisurf` <- function(x, what = c("contour","persp","gam"),
add = FALSE, bubble = FALSE, col = "red", cex = 1,
nlevels = 10, levels, labcex = 0.6,
lwd.cl = par("lwd"), ...) {
what <- match.arg(what)
y <- x$model$y
x1 <- x$model$x1
x2 <- x$model$x2
X <- x$grid$x
Y <- x$grid$y
Z <- x$grid$z
force(col)
force(cex)
if(isTRUE(all.equal(what, "contour"))) {
if(!add) {
if(bubble) {
if (is.numeric(bubble))
cex <- bubble
cex <- (y - min(y))/diff(range(y)) * (cex-0.4) + 0.4
}
plot(x1, x2, asp = 1, cex = cex, ...)
}
if (missing(levels))
levels <- pretty(range(x$grid$z, finite = TRUE), nlevels)
contour(X, Y, Z, col = col, add = TRUE,
levels = levels, labcex = labcex,
drawlabels = !is.null(labcex) && labcex > 0,
lwd = lwd.cl)
} else if(isTRUE(all.equal(what, "persp"))) {
persp(X, Y, Z, col = col, cex = cex, ...)
} else {
class(x) <- class(x)[-1]
plot(x, ...) ##col = col, cex = cex, ...)
class(x) <- c("ordisurf", class(x))
}
invisible(x)
}