]> git.donarmstrong.com Git - ape.git/blobdiff - R/nodelabels.R
few corrections and fixes
[ape.git] / R / nodelabels.R
index 5526b017b54733e48c14e44c099d3f8715d4aecb..9d5b39ce46d9fde1206a47b4c5e67e50fcd2492e 100644 (file)
@@ -1,4 +1,4 @@
-## nodelabels.R (2010-01-30)
+## nodelabels.R (2010-03-12)
 
 ##   Labelling Trees
 
@@ -98,6 +98,9 @@ BOTHlabels <- function(text, sel, XX, YY, adj, frame, pch, thermo,
             rect(xl, yb + rowSums(thermo[, 1:(i - 1), drop = FALSE]),
                  xr, yb + rowSums(thermo[, 1:i]),
                  border = NA, col = piecol[i])
+        ## check for NA's before drawing the borders
+        s <- apply(thermo, 1, function(xx) any(is.na(xx)))
+        xl[s] <-  xr[s] <- NA
         rect(xl, yb, xr, yb + height, border = "black")
         segments(xl, YY, xl - width/5, YY)
         segments(xr, YY, xr + width/5, YY)
@@ -109,8 +112,10 @@ BOTHlabels <- function(text, sel, XX, YY, adj, frame, pch, thermo,
         xrad <- rep(xrad, length(sel))
         XX <- XX + adj[1] - 0.5
         YY <- YY + adj[2] - 0.5
-        for (i in 1:length(sel))
+        for (i in 1:length(sel)) {
+            if (any(is.na(pie[i, ]))) next
             floating.pie.asp(XX[i], YY[i], pie[i, ], radius = xrad[i], col = piecol)
+        }
     }
     if (!is.null(text)) text(XX, YY, text, adj = adj, col = col, ...)
     if (!is.null(pch)) points(XX + adj[1] - 0.5, YY + adj[2] - 0.5,