]> git.donarmstrong.com Git - ape.git/blobdiff - R/scales.R
update for ape 2.1-2
[ape.git] / R / scales.R
index 69c9f46d638d43d166f504ede4e4db8adaf0e382..c8da7e79ec54692c272fcd7a1851ca5293cf1bb6 100644 (file)
@@ -1,4 +1,4 @@
-## scales.R (2008-02-08)
+## scales.R (2008-02-28)
 
 ##   Add a Scale Bar or Axis to a Phylogeny Plot
 
@@ -12,9 +12,9 @@
 
 add.scale.bar <- function(x = 0, y = 1, length = NULL, ...)
 {
+    lastPP <- get("last_plot.phylo", envir = .PlotPhyloEnv)
     if (is.null(length)) {
-        nb.digit <- ceiling(log10(mean(get("last_plot.phylo$xx",
-                                           envir = .PlotPhyloEnv)))) - 2
+        nb.digit <- ceiling(log10(mean(lastPP$xx))) - 2
         length <- eval(parse(text = paste("1e", nb.digit, sep = "")))
     }
     segments(x, y, x + length, y)
@@ -23,23 +23,20 @@ add.scale.bar <- function(x = 0, y = 1, length = NULL, ...)
 
 axisPhylo <- function(side = 1, ...)
 {
-    type <- get("last_plot.phylo$type", envir = .PlotPhyloEnv)
-    direction <- get("last_plot.phylo$direction", envir = .PlotPhyloEnv)
-    if (type %in% c("phylogram", "cladogram")) {
-        if (direction %in% c("rightwards", "leftwards")) {
-            xx <- get("last_plot.phylo$xx", envir = .PlotPhyloEnv)
-            x <- pretty(xx)
-            if (direction == "rightwards") maxi <- max(xx)
+    lastPP <- get("last_plot.phylo", envir = .PlotPhyloEnv)
+    if (lastPP$type %in% c("phylogram", "cladogram")) {
+        if (lastPP$direction %in% c("rightwards", "leftwards")) {
+            x <- pretty(lastPP$xx)
+            if (lastPP$direction == "rightwards") maxi <- max(lastPP$xx)
             else {
-                maxi <- min(xx)
+                maxi <- min(lastPP$xx)
                 x <- -x
             }
         } else {
-            yy <- get("last_plot.phylo$yy", envir = .PlotPhyloEnv)
-            x <- pretty(yy)
-            if (direction == "upwards") maxi <- max(yy)
+            x <- pretty(lastPP$yy)
+            if (lastPP$direction == "upwards") maxi <- max(lastPP$yy)
             else {
-                maxi <- min(yy)
+                maxi <- min(lastPP$yy)
                 x <- -x
             }
         }