X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=R%2Fltt.plot.R;h=a7eae04323169877a30c86b15984fa2256936e77;hb=3ece2ec76da287a8a86339827cc44e193fe16cdd;hp=2a0179c4d6538fa294674dde6cfaffb603711fe4;hpb=cc052f3adebcde0dbf4531719f84dfc349373f2c;p=ape.git diff --git a/R/ltt.plot.R b/R/ltt.plot.R index 2a0179c..a7eae04 100644 --- a/R/ltt.plot.R +++ b/R/ltt.plot.R @@ -1,15 +1,16 @@ -## ltt.plot.R (2008-02-22) +## ltt.plot.R (2009-05-10) ## Lineages Through Time Plot -## Copyright 2002-2008 Emmanuel Paradis +## Copyright 2002-2009 Emmanuel Paradis ## This file is part of the R-package `ape'. ## See the file ../COPYING for licensing issues. ltt.plot <- function(phy, xlab = "Time", ylab = "N", ...) { - if (class(phy) != "phylo") stop('object "phy" is not of class "phylo"') + if (!inherits(phy, "phylo")) stop('object "phy" is not of class "phylo"') + if (!is.binary.tree(phy)) phy <- multi2di(phy) time <- sort(branching.times(phy), decreasing = TRUE) N <- 1:(length(time) + 1) plot.default(-c(time, 0), N, xlab = xlab, ylab = ylab, @@ -18,6 +19,7 @@ ltt.plot <- function(phy, xlab = "Time", ylab = "N", ...) ltt.lines <- function(phy, ...) { + if (!is.binary.tree(phy)) phy <- multi2di(phy) time <- sort(branching.times(phy), decreasing = TRUE) N <- 1:(length(time) + 1) lines(-c(time, 0), N, type = "S", ...) @@ -27,12 +29,13 @@ mltt.plot <- function(phy, ..., dcol = TRUE, dlty = FALSE, legend = TRUE, xlab = "Time", ylab = "N", log = "") { ltt.xy <- function(phy) { + if (!is.binary.tree(phy)) phy <- multi2di(phy) x <- -c(sort(branching.times(phy), decreasing = TRUE), 0) names(x) <- NULL y <- 1:length(x) cbind(x, y) } - if (class(phy) == "phylo") { + if (inherits(phy, "phylo")) { # if a tree of class "phylo" TREES <- list(ltt.xy(phy)) names(TREES) <- deparse(substitute(phy)) } else { # a list of trees