]> git.donarmstrong.com Git - ape.git/commitdiff
bug fixes in plot.phylo
authorparadis <paradis@6e262413-ae40-0410-9e79-b911bd7a66b7>
Thu, 17 Feb 2011 17:04:12 +0000 (17:04 +0000)
committerparadis <paradis@6e262413-ae40-0410-9e79-b911bd7a66b7>
Thu, 17 Feb 2011 17:04:12 +0000 (17:04 +0000)
git-svn-id: https://svn.mpl.ird.fr/ape/dev/ape@146 6e262413-ae40-0410-9e79-b911bd7a66b7

ChangeLog
DESCRIPTION
R/plot.phylo.R
man/corMartins.Rd
man/rotate.Rd
man/vcv.phylo.Rd

index 8480ce8d82dec01af58e8f2dba26fcf09b40c9b7..72198d9dd284170c46251cf6ad8274c7ba1adcf2 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -20,6 +20,10 @@ BUG FIXES
     o plot.phylo() did not recycle values of 'font', 'cex' and
       'tip.color' correctly when type = "fan" or "radial".
 
+    o plot.phylo() ignored 'label.offset' when type = "radial", "fan", or
+      "unrooted" with lab4ut = "axial" (the placement of tip labels still
+      needs to be improved with lab4ut = "horizontal").
+
 
 OTHER CHANGES
 
index 17dfadf79278dfd6c08e38cba013b2a98073f61c..1bf01d20a414d17b121e63b925f5e6d792ff509c 100644 (file)
@@ -1,6 +1,6 @@
 Package: ape
 Version: 2.6-3
-Date: 2011-02-11
+Date: 2011-02-17
 Title: Analyses of Phylogenetics and Evolution
 Author: Emmanuel Paradis, Ben Bolker, Julien Claude, Hoa Sien Cuong, Richard Desper, Benoit Durand, Julien Dutheil, Olivier Gascuel, Christoph Heibl, Daniel Lawson, Vincent Lefort, Pierre Legendre, Jim Lemon, Yvonnick Noel, Johan Nylander, Rainer Opgen-Rhein, Klaus Schliep, Korbinian Strimmer, Damien de Vienne
 Maintainer: Emmanuel Paradis <Emmanuel.Paradis@ird.fr>
index 69f08660f1afa189e9461ed00f51b330d78baf71..b2273ca2ef1679a05924abc2541aac249e556f9d 100644 (file)
@@ -1,4 +1,4 @@
-## plot.phylo.R (2011-02-11)
+## plot.phylo.R (2011-02-17)
 
 ##   Plot Phylogenies
 
@@ -351,44 +351,58 @@ plot.phylo <- function(x, type = "phylogram", use.edge.length = TRUE,
                 y.adj[sel] <- strheight(x$tip.label)[sel] / 2
                 sel <- XY$axe < -pi / 4 & XY$axe > -0.75 * pi
                 y.adj[sel] <- -strheight(x$tip.label)[sel] * 0.75
-                text(xx[1:Ntip] + x.adj*cex, yy[1:Ntip] + y.adj*cex,
+                text(xx[1:Ntip] + x.adj * cex, yy[1:Ntip] + y.adj * cex,
                      x$tip.label, adj = c(adj, 0), font = font,
                      srt = srt, cex = cex, col = tip.color)
             } else { # if lab4ut == "axial"
-                adj <- as.numeric(abs(XY$axe) > pi/2)
-                srt <- 180*XY$axe/pi
-                srt[as.logical(adj)] <- srt[as.logical(adj)] - 180
+                adj <- abs(XY$axe) > pi/2
+                srt <- 180 * XY$axe / pi
+                srt[adj] <- srt[adj] - 180
+                adj <- as.numeric(adj)
+                xx.tips <- xx[1:Ntip]
+                yy.tips <- yy[1:Ntip]
+                if (label.offset) {
+                    xx.tips <- xx.tips + label.offset * cos(XY$axe)
+                    yy.tips <- yy.tips + label.offset * sin(XY$axe)
+                }
                 ## `srt' takes only a single value, so can't vectorize this:
                 ## (and need to 'elongate' these vectors:)
                 font <- rep(font, length.out = Ntip)
                 tip.color <- rep(tip.color, length.out = Ntip)
                 cex <- rep(cex, length.out = Ntip)
                 for (i in 1:Ntip)
-                  text(xx[i], yy[i], cex = cex[i], x$tip.label[i], adj = adj[i],
-                       font = font[i], srt = srt[i], col = tip.color[i])
+                    text(xx.tips[i], yy.tips[i], cex = cex[i],
+                         x$tip.label[i], adj = adj[i], font = font[i],
+                         srt = srt[i], col = tip.color[i])
             }
         }
         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[1:Ntip], xx.tips)*180/pi
+            angle <- atan2(yy.tips, xx.tips) # in radians
+            if (label.offset) {
+                xx.tips <- xx.tips + label.offset * cos(angle)
+                yy.tips <- yy.tips + label.offset * sin(angle)
+            }
             s <- xx.tips < 0
+            angle <- angle * 180/pi # switch to degrees
             angle[s] <- angle[s] + 180
-            adj <- numeric(Ntip)
-            adj[xx.tips < 0] <- 1
+            adj <- as.numeric(s)
             ## `srt' takes only a single value, so can't vectorize this:
             ## (and need to 'elongate' these vectors:)
             font <- rep(font, length.out = Ntip)
             tip.color <- rep(tip.color, length.out = Ntip)
             cex <- rep(cex, length.out = Ntip)
             for (i in 1:Ntip)
-                text(xx[i], yy[i], x$tip.label[i], font = font[i], cex = cex[i],
-                     srt = angle[i], adj = adj[i], col = tip.color[i])
+                text(xx.tips[i], yy.tips[i], x$tip.label[i], font = font[i],
+                     cex = cex[i], srt = angle[i], adj = adj[i],
+                     col = tip.color[i])
         }
     }
     if (show.node.label)
-      text(xx[ROOT:length(xx)] + label.offset, yy[ROOT:length(yy)],
-           x$node.label, adj = adj, font = font, srt = srt, cex = cex)
+        text(xx[ROOT:length(xx)] + label.offset, yy[ROOT:length(yy)],
+             x$node.label, adj = adj, font = font, srt = srt, cex = cex)
     L <- list(type = type, use.edge.length = use.edge.length,
               node.pos = node.pos, show.tip.label = show.tip.label,
               show.node.label = show.node.label, font = font,
index f6f673a24add168d4c86b7b7934f56efd500ecde..7e27d7c92453a5a502e9cd1c555d3bf8f604d3b1 100644 (file)
@@ -4,7 +4,7 @@
 \alias{corMatrix.corMartins}
 \title{Martins's (1997) Correlation Structure}
 \usage{
-corMartins(value, phy, form=~1, fixed = FALSE)
+corMartins(value, phy, form = ~1, fixed = FALSE)
 \method{coef}{corMartins}(object, unconstrained = TRUE, ...)
 \method{corMatrix}{corMartins}(object,
                covariate = getCovariate(object), corr = TRUE, ...)
index 850247a28cf4675f29b9b389efed8a8c5095b9d0..a901bf827bc1ad7cd81c53ddb969cba93643289d 100644 (file)
@@ -39,13 +39,11 @@ nodelabels()
 tre.new <- rotate(tre, 30)
 
 # compare the results:
-X11() # open new graphical device
 par(mfrow=c(1,2)) # devide graphical device
 plot(tre) # plot old tre
 plot(tre.new) # plot new tree
 
 # visualize labels of terminal nodes:
-X11() # open new graphical device
 plot.phylo(tre)
 tiplabels()
 
@@ -53,7 +51,6 @@ tiplabels()
 tre.new <- rotate(tre, c(12, 21))
 
 # compare the results:
-X11() # open new graphical device
 par(mfrow=c(1,2)) # devide graphical device
 plot(tre) # plot old tre
 plot(tre.new) # plot new tree
@@ -62,7 +59,6 @@ plot(tre.new) # plot new tree
 tre.new <- rotate(tre, c("t3", "t14"))
 
 # compare the results:
-X11() # open new graphical device
 par(mfrow=c(1,2)) # devide graphical device
 plot(tre) # plot old tre
 plot(tre.new) # plot new tree
index 702ca63753eab06731a6fd13bf9b82ec44106e67..f48e5740a4e8de72f5810fdb9a5165614ddc98a8 100644 (file)
@@ -11,7 +11,8 @@ vcv(phy, ...)
 \arguments{
   \item{phy}{an object of the correct class (see above).}
   \item{model}{a character giving the model used to compute the
-    variances and covariances; only \code{"Brownian"} is available.}
+    variances and covariances; only \code{"Brownian"} is available (for
+    other models, a correlation structure may be used).}
   \item{corr}{a logical indicating whether the correlation matrix should
     be returned (\code{TRUE}); by default the variance-covariance matrix
     is returned (\code{FALSE}).}