File: plot.isomap.R

package info (click to toggle)
r-cran-vegan 2.5-7%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 5,564 kB
  • sloc: ansic: 2,275; fortran: 1,088; sh: 42; makefile: 2
file content (25 lines) | stat: -rw-r--r-- 840 bytes parent folder | download | duplicates (4)
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
`plot.isomap` <-
    function (x, net = TRUE, n.col = "gray", type = "points", ...) 
{
    type <- match.arg(type, c("points", "text", "none"))
    if (!net) {
        pl <- ordiplot(x, display="sites", type = type, ...)
    } else {
        pl <- ordiplot(x, display = "sites", type = "none", ...)
        z <- scores(pl, "sites")
        k <- x$net
        ## recycle colour for points
        n.col <- rep(n.col, length = nrow(z))
        n.col <- col2rgb(n.col)/255
        ## get average of colours of connected points
        n.col <- (n.col[,k[,1]] + n.col[,k[,2]])/2
        n.col <- rgb(t(n.col))
        segments(z[k[,1],1], z[k[,1],2], z[k[,2],1], z[k[,2],2], col=n.col)
        if (type == "points")
            points(pl, "sites", ...)
        else if (type == "text")
            ordilabel(pl, ...)
    }
    invisible(pl)
}