]> git.donarmstrong.com Git - ape.git/commitdiff
fixing add.scale.bar()
authorparadis <paradis@6e262413-ae40-0410-9e79-b911bd7a66b7>
Thu, 23 Jul 2009 08:13:39 +0000 (08:13 +0000)
committerparadis <paradis@6e262413-ae40-0410-9e79-b911bd7a66b7>
Thu, 23 Jul 2009 08:13:39 +0000 (08:13 +0000)
git-svn-id: https://svn.mpl.ird.fr/ape/dev/ape@84 6e262413-ae40-0410-9e79-b911bd7a66b7

ChangeLog
DESCRIPTION
R/scales.R
Thanks
man/add.scale.bar.Rd

index c3a2a844a0e098a57e65e6d93e27e1ce3439377b..678bba7b17c60151cf7e1dd0924e69c7ae72341e 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+               CHANGES IN APE VERSION 2.3-3
+
+
+BUG FIXES
+
+    o 
+
+
+
                CHANGES IN APE VERSION 2.3-2
 
 
index 8cf6cde9ca7e62e5ff3d588f43c43ccdb8364f8d..55c662cf89431a42ad893933b8cb2940585844a4 100644 (file)
@@ -1,6 +1,6 @@
 Package: ape
-Version: 2.3-2
-Date: 2009-07-17
+Version: 2.3-3
+Date: 2009-07-22
 Title: Analyses of Phylogenetics and Evolution
 Author: Emmanuel Paradis, Ben Bolker, Julien Claude, Hoa Sien Cuong, Richard Desper, Benoit Durand, Julien Dutheil, Olivier Gascuel, Gangolf Jobb, Christoph Heibl, Daniel Lawson, Vincent Lefort, Pierre Legendre, Jim Lemon, Yvonnick Noel, Johan Nylander, Rainer Opgen-Rhein, Korbinian Strimmer, Damien de Vienne
 Maintainer: Emmanuel Paradis <Emmanuel.Paradis@ird.fr>
index c8da7e79ec54692c272fcd7a1851ca5293cf1bb6..01f23f5fe96c8e263baf0f319284353de9b5b2ce 100644 (file)
@@ -1,24 +1,53 @@
-## scales.R (2008-02-28)
+## scales.R (2009-07-23)
 
 ##   Add a Scale Bar or Axis to a Phylogeny Plot
 
 ## add.scale.bar: add a scale bar to a phylogeny plot
 ## axisPhylo: add a scale axis on the side of a phylogeny 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.
 
-add.scale.bar <- function(x = 0, y = 1, length = NULL, ...)
+add.scale.bar <- function(x, y, length = NULL, ...)
 {
     lastPP <- get("last_plot.phylo", envir = .PlotPhyloEnv)
     if (is.null(length)) {
-        nb.digit <- ceiling(log10(mean(lastPP$xx))) - 2
+        nb.digit <-
+          if (lastPP$direction %in% c("rightwards", "leftwards")) diff(range(lastPP$xx))
+          else diff(range(lastPP$yy))
+        nb.digit <- ceiling(log10(nb.digit)) - 2
         length <- eval(parse(text = paste("1e", nb.digit, sep = "")))
     }
-    segments(x, y, x + length, y)
-    text(x + length * 1.1, y, as.character(length), adj = c(0, 0.5), ...)
+    if (missing(x) || missing(y)) {
+        switch(lastPP$direction,
+               "rightwards" = {
+                   x <- 0
+                   y <- 1
+                   segments(x, y, x + length, y)
+                   text(x + length * 1.1, y, as.character(length), adj = c(0, 0.5), ...)
+               },
+               "leftwards" = {
+                   x <- max(lastPP$xx)
+                   y <- 1
+                   segments(x - length, y, x, y)
+                   text(x - length * 1.1, y, as.character(length), adj = c(1, 0.5), ...)
+               },
+               "upwards" = {
+                   x <- max(lastPP$xx)
+                   y <- 0
+                   segments(x, y, x, y + length)
+                   text(x, y + length * 1.1, as.character(length), adj = c(0, 0.5), srt = 90, ...)
+               },
+               "downwards" = {
+                   x <- 1
+                   y <- max(lastPP$yy)
+                   segments(x, y - length, x, y)
+                   text(x, y - length * 1.1, as.character(length), adj = c(0, 0.5), srt = 270, ...)
+               }
+         )
+    }
 }
 
 axisPhylo <- function(side = 1, ...)
diff --git a/Thanks b/Thanks
index abbeca8eb86ecef466cd7cd081a514be52419a46..c9fea53751098516d71ae53409dc590bc652ddd4 100644 (file)
--- a/Thanks
+++ b/Thanks
@@ -5,7 +5,7 @@ Many users gave important feed-back with their encouragements,
 comments, or bug reports: thanks to all of you!
 
 Significant bug fixes were provided by Cécile Ané, James Bullard,
-Éric Durand, Olivier François, Rich FitzJohn Bret Larget, Nick Matzke,
+Éric Durand, Olivier François, Rich FitzJohn, Bret Larget, Nick Matzke,
 Elizabeth Purdom, Dan Rabosky, Klaus Schliep, Tim Wallstrom, Li-San
 Wang, Yan Wong, and Peter Wragg. Contact me if I forgot someone.
 
index 3ae6e596e805520557dc2dd9725b5214f6c0a456..57a1daafd5bbd6aba6a40ee534ed29b56874d040 100644 (file)
@@ -2,11 +2,11 @@
 \alias{add.scale.bar}
 \title{Add a Scale Bar to a Phylogeny Plot}
 \usage{
-add.scale.bar(x = 0, y = 1, length = NULL, ...)
+add.scale.bar(x, y, length = NULL, ...)
 }
 \arguments{
-  \item{x}{x location of the bar.}
-  \item{y}{y location of the bar.}
+  \item{x}{x location of the bar (can be left missing).}
+  \item{y}{y location of the bar (can be left missing).}
   \item{length}{a numeric value giving the length of the scale bar. If
     none is supplied, a value is calculated from the data.}
   \item{...}{further arguments to be passed to \code{text}.}
@@ -17,9 +17,9 @@ add.scale.bar(x = 0, y = 1, length = NULL, ...)
   device.
 }
 \details{
-  As from version 1.4 of ape, the options of this function have been
-  redefined, and have now default values. By default, the scale bar is
-  plotted on the left bottom corner of the plot.
+  By default, the bar is placed in a corner of the graph depending on
+  the direction of the tree. Otherwise both \code{x} and \code{y} must
+  be specified (if only one  is given it is ignored).
 
   The further arguments (\code{...}) are used to format the text. They
   may be \code{font}, \code{cex}, \code{col}, and so on (see examples