File: plot.preston.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 (50 lines) | stat: -rw-r--r-- 1,581 bytes parent folder | download | duplicates (6)
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
### Similar plotting functions as plot.prestonfit/fisherfit, but only
### for the data without the fitted models. These can be used with the
### result of as.preston(), as.fisher().

## as plot.prestonfit, but plots only the bars of as.preston()

`plot.preston` <-
        function (x, xlab = "Frequency", ylab = "Species", bar.col = "skyblue", 
                  ...) 
{
    freq <- x
    oct <- as.numeric(names(freq))
    noct <- max(oct) + 1
    plot(oct, freq, type = "n", ylim = c(0, max(freq)),
         xlim = c(-1, max(oct)), ylab = ylab, xlab = xlab, axes = FALSE, ...)
    axis(2)
    axis(1, at = 0:noct, labels = 2^(0:noct))
    box()
    rect(oct - 1, 0, oct, freq, col = bar.col, ...)
    invisible()
}


`lines.preston` <-
    function(x, xadjust = 0.5, ...)
{
    oct <- as.numeric(names(x)) - xadjust 
    lines(oct, x, ...)
}

## as plot.fisherfit, but plots only the bars of as.fisherfit

`plot.fisher` <-
    function(x, xlab = "Frequency", ylab = "Species", bar.col = "skyblue",
             kind = c("bar", "hiplot", "points", "lines"), add = FALSE,
             ...)
{
    kind <- match.arg(kind)
    freq <- as.numeric(names(x))
    if (!add)
        plot(freq, x, ylab=ylab, xlab=xlab,
             ylim=c(0,max(x)),  xlim=c(0.5, max(freq)+0.5), type="n", ...)
    switch(kind,
           "bar" = rect(freq-0.5,0,freq+0.5,x, col=bar.col, ...),
           "hiplot" = points(freq, x, col =bar.col, type = "h",  ...),
           "points" = points(freq, x, col =bar.col, ...),
           "lines" = lines(freq, x, col =bar.col, ...)
       )
    invisible()
}