File: plot.popsize.R

package info (click to toggle)
r-cran-ape 5.8-1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 3,676 kB
  • sloc: ansic: 7,676; cpp: 116; sh: 17; makefile: 2
file content (45 lines) | stat: -rw-r--r-- 1,342 bytes parent folder | download | duplicates (3)
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
## plot.popsize.R (2004-07-4) modified by EP (2019-01-29)

##   Plot population size in dependence of time

## Copyright 2004 Rainer Opgen-Rhein and Korbinian Strimmer

## This file is part of the R-package `ape'.
## See the file ../COPYING for licensing issues.

plot.popsize <-
    function(x, show.median = TRUE, show.years = FALSE,
             subst.rate, present.year, xlab = NULL,
             ylab = "Effective population size",
             log = "y", ...)
{
    ylim <- range(x[, 2:5], na.rm = TRUE)
    x1 <- x[, 1]
    if (show.years) {
        x1 <- -x1/subst.rate + present.year
        if (is.null(xlab)) xlab <- "Time (years)"
    } else {
        if (is.null(xlab))
            xlab <- "Time (past to present in units of substitutions)"
    }
    xlim <- range(x1, na.rm = TRUE)

    j <- if (show.median) 3 else 2

    plot(x1, x[, j], type = "s", xlim = xlim, ylim = ylim,
         xlab = xlab, ylab = ylab, log = log, lwd = 2.5, ...)

    lines(x1, x[, 4], ...)
    lines(x1, x[, 5], ...)
}

lines.popsize <- function(x, show.median = TRUE, show.years = FALSE,
                          subst.rate, present.year, ...)
{
    x1 <- x[, 1]
    if (show.years) x1 <- -x1/subst.rate + present.year
    j <- if (show.median) 3 else 2
    lines(x1, x[, j], lwd = 2.5, ...)
    lines(x1, x[, 4], ...)
    lines(x1, x[, 5], ...)
}