]> git.donarmstrong.com Git - ape.git/blobdiff - R/plot.phylo.R
fix a few bugs + correct some the man page of sh.test()
[ape.git] / R / plot.phylo.R
index ff2317c87628357d21a758d1592d60a763e6dbe8..ca3ff1ce570960fa9c86b35f0cdc93a146312da2 100644 (file)
@@ -1,4 +1,4 @@
-## plot.phylo.R (2008-01-12)
+## plot.phylo.R (2008-05-08)
 
 ##   Plot Phylogenies
 
@@ -245,9 +245,10 @@ plot.phylo <- function(x, type = "phylogram", use.edge.length = TRUE,
         if (direction == "leftwards") x.lim[2] <- x.lim[2] + x$root.edge
         if (direction == "downwards") y.lim[2] <- y.lim[2] + x$root.edge
     }
-
+    ## fix by Klaus Schliep (2008-03-28):
+    asp <- if (type %in% c("fan", "radial")) 1 else NA
     plot(0, type = "n", xlim = x.lim, ylim = y.lim, xlab = "",
-         ylab = "", xaxt = "n", yaxt = "n", bty = "n", ...)
+         ylab = "", xaxt = "n", yaxt = "n", bty = "n", asp = asp, ...)
     if (is.null(adj))
       adj <- if (phyloORclado && direction == "leftwards") 1 else 0
     if (phyloORclado) {
@@ -328,7 +329,7 @@ plot.phylo <- function(x, type = "phylogram", use.edge.length = TRUE,
         if (type %in% c("fan", "radial")) {
             xx.scaled <- xx[1:Ntip]
             if (type == "fan") { # no need if type == "radial"
-                maxx <- max(xx.scaled)
+                maxx <- max(abs(xx.scaled))
                 if (maxx > 1) xx.scaled <- xx.scaled/maxx
             }
             angle <- acos(xx.scaled)*180/pi
@@ -356,7 +357,8 @@ plot.phylo <- function(x, type = "phylogram", use.edge.length = TRUE,
               label.offset = label.offset, x.lim = x.lim, y.lim = y.lim,
               direction = direction, tip.color = tip.color,
               Ntip = Ntip, Nnode = Nnode)
-    .last_plot.phylo <<- c(L, list(edge = xe, xx = xx, yy = yy))
+    assign("last_plot.phylo", c(L, list(edge = xe, xx = xx, yy = yy)),
+           envir = .PlotPhyloEnv)
     invisible(L)
 }
 
@@ -514,5 +516,5 @@ plot.multiPhylo <- function(x, layout = 1, ...)
         par(ask = TRUE)
         on.exit(par(ask = FALSE))
     }
-    for (i in x) plot(i, ...)
+    for (i in 1:length(x)) plot(x[[i]], ...)
 }