R/ordixyplot.R

Defines functions `ordixyplot`

`ordixyplot` <-
    function(x, data = NULL, formula, display = "sites", choices=1:3,
             panel = "panel.ordi", aspect = "iso", envfit,
             type = c("p", "biplot"),  ...)
{
    localXyplot <- function(..., shrink, origin, scaling) xyplot(...)
    p <- as.data.frame(scores(x, display = display, choices = choices, ...))
    if (!is.null(data))
        p <- cbind(p, data)
    if (missing(formula)) {
        v <- colnames(p)
        formula <- as.formula(paste(v[2], "~", v[1]))
    }
    if ("biplot" %in% type && ((!is.null(x$CCA) && x$CCA$rank > 0) ||
                                   !missing(envfit))) {
        if (missing(envfit))
            envfit <- NULL
        env <- ordilattice.getEnvfit(formula, x, envfit, choices, ...)
        if (!is.null(env$arrows)) {
            mul <- apply(p[,colnames(env$arrows)], 2, range)/apply(env$arrows, 2, range)
            mul <- min(mul[is.finite(mul) & mul > 0])
            env$arrows <- mul * env$arrows
        }
    } else {
        env <- NULL
    }
    ## plot polygon for all data plus superpose polygons for each panel
    if ("polygon" %in% type) {
        pol <- p[, all.vars(formula)[2:1]]
        pol <- pol[chull(pol),]
    } else {
        pol <- NULL
    }
    localXyplot(formula, data = p, panel = panel,  aspect = aspect,
                biplot = env, polygon = pol, type = type, ...)
}

Try the vegan package in your browser

Any scripts or data that you put into this service are public.

vegan documentation built on Sept. 11, 2024, 7:57 p.m.