]> git.donarmstrong.com Git - ape.git/blobdiff - R/plot.phylo.R
a few changes....
[ape.git] / R / plot.phylo.R
index 4c23c6f0032361e6c3b6181941cbfd4c83ad3f24..96d9aa4e590a6f4b9262335d480fc197ea950076 100644 (file)
@@ -1,4 +1,4 @@
-## plot.phylo.R (2012-10-20)
+## plot.phylo.R (2012-12-19)
 
 ##   Plot Phylogenies
 
@@ -15,7 +15,8 @@ plot.phylo <-
              adj = NULL, srt = 0, no.margin = FALSE, root.edge = FALSE,
              label.offset = 0, underscore = FALSE, x.lim = NULL,
              y.lim = NULL, direction = "rightwards", lab4ut = "horizontal",
-             tip.color = "black", plot = TRUE, rotate.tree = 0, ...)
+             tip.color = "black", plot = TRUE, rotate.tree = 0,
+             open.angle = 0, ...)
 {
     Ntip <- length(x$tip.label)
     if (Ntip < 2) {
@@ -122,13 +123,15 @@ plot.phylo <-
             xx <- .nodeDepthEdgelength(Ntip, Nnode, z$edge, Nedge, z$edge.length)
         }
     } else {
-    rotate.tree <- 2 * pi * rotate.tree/360
+    twopi <- 2 * pi
+    rotate.tree <- twopi * rotate.tree/360
     switch(type, "fan" = {
         ## if the tips are not in the same order in tip.label
         ## and in edge[, 2], we must reorder the angles: we
         ## use `xx' to store temporarily the angles
         TIPS <- x$edge[which(x$edge[, 2] <= Ntip), 2]
-        xx <- seq(0, 2*pi*(1 - 1/Ntip), 2*pi/Ntip)
+        xx <- seq(0, twopi * (1 - 1/Ntip) - twopi * open.angle/360,
+                  length.out = Ntip)
         theta <- double(Ntip)
         theta[TIPS] <- xx
         theta <- c(theta, numeric(Nnode))
@@ -140,8 +143,8 @@ plot.phylo <-
             r <- 1/r
         }
         theta <- theta + rotate.tree
-        xx <- r*cos(theta)
-        yy <- r*sin(theta)
+        xx <- r * cos(theta)
+        yy <- r * sin(theta)
     }, "unrooted" = {
         nb.sp <- .nodeDepth(Ntip, Nnode, z$edge, Nedge)
         XY <- if (use.edge.length)
@@ -157,7 +160,7 @@ plot.phylo <-
         ## radius:
         X <- 1 - X/Ntip
         ## angle (1st compute the angles for the tips):
-        yy <- c((1:Ntip)*2*pi/Ntip, rep(0, Nnode))
+        yy <- c((1:Ntip)*twopi/Ntip, rep(0, Nnode))
         Y <- .nodeHeight(Ntip, Nnode, z$edge, Nedge, yy)
         xx <- X * cos(Y + rotate.tree)
         yy <- X * sin(Y + rotate.tree)
@@ -375,7 +378,6 @@ if (plot) {
         if (type %in% c("fan", "radial")) {
             xx.tips <- xx[1:Ntip]
             yy.tips <- yy[1:Ntip]
-            ## using atan2 considerably facilitates things compared to acos...
             angle <- atan2(yy.tips, xx.tips) # in radians
             if (label.offset) {
                 xx.tips <- xx.tips + label.offset * cos(angle)