[Vegan-commits] r2173 - in pkg/vegan: R inst man

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Tue May 22 15:58:52 CEST 2012


Author: jarioksa
Date: 2012-05-22 15:58:52 +0200 (Tue, 22 May 2012)
New Revision: 2173

Modified:
   pkg/vegan/R/ordihull.R
   pkg/vegan/inst/ChangeLog
   pkg/vegan/man/ordihull.Rd
Log:
ordihull adds labels after drawing all hulls so that they are not shadowed by filled hulls

Modified: pkg/vegan/R/ordihull.R
===================================================================
--- pkg/vegan/R/ordihull.R	2012-05-22 09:19:33 UTC (rev 2172)
+++ pkg/vegan/R/ordihull.R	2012-05-22 13:58:52 UTC (rev 2173)
@@ -1,7 +1,7 @@
-"ordihull" <-
+`ordihull` <-
     function (ord, groups, display = "sites",
               draw = c("lines", "polygon", "none"),
-              show.groups, label = FALSE, ...)
+              col = NULL, show.groups, label = FALSE, ...)
 {
     draw <- match.arg(draw)
     pts <- scores(ord, display = display, ...)
@@ -13,6 +13,8 @@
     out <- seq(along = groups)
     inds <- names(table(groups))
     res <- list()
+    if (label)
+        cntrs <- names <- NULL
     ## Remove NA scores
     kk <- complete.cases(pts)
     for (is in inds) {
@@ -22,17 +24,25 @@
             hpts <- chull(X)
             hpts <- c(hpts, hpts[1])
             if (draw == "lines")
-                ordiArgAbsorber(X[hpts, ], FUN = lines, ...)
+                ordiArgAbsorber(X[hpts, ], FUN = lines,
+                                col = if(is.null(col)) par("fg") else col, ...)
             else if (draw == "polygon")
-                ordiArgAbsorber(X[hpts,], FUN = polygon, ...)
+                ordiArgAbsorber(X[hpts,], FUN = polygon, col = col, ...)
             if (label && draw != "none") {
-                cntr <- colMeans(X)
-                ordiArgAbsorber(cntr[1], cntr[2], labels = is,
-                                FUN = text, ...)
+                cntrs <- rbind(cntrs, colMeans(X[hpts,]))
+                names <- c(names, is)
             }
             res[[is]] <- X[hpts,]
         }
     }
+    if (label && draw != "none") {
+        if (draw == "lines")
+            ordiArgAbsorber(cntrs[,1], cntrs[,2], labels = names,
+                            col = col, FUN = text, ...)
+        else
+            ordiArgAbsorber(cntrs, labels = names, col = NULL,
+                            FUN = ordilabel, ...)
+    }
     class(res) <- "ordihull"
     invisible(res)
 }

Modified: pkg/vegan/inst/ChangeLog
===================================================================
--- pkg/vegan/inst/ChangeLog	2012-05-22 09:19:33 UTC (rev 2172)
+++ pkg/vegan/inst/ChangeLog	2012-05-22 13:58:52 UTC (rev 2173)
@@ -4,6 +4,11 @@
 
 Version 2.1-16 (opened May 11, 2012)
 
+	* ordihull: gained explicit 'col' argument and adds labels after
+	drawing convex hulls so that filled hulls (with 'draw = "polygon")
+	do not cover labels. With these changes, the behaviour of
+	ordihull() is similar to ordiellipse().
+
 	* monoMDS: Count only above-zero non-NA dissimilarities for the
 	absolute lower limit of sufficient data. 
 

Modified: pkg/vegan/man/ordihull.Rd
===================================================================
--- pkg/vegan/man/ordihull.Rd	2012-05-22 09:19:33 UTC (rev 2172)
+++ pkg/vegan/man/ordihull.Rd	2012-05-22 13:58:52 UTC (rev 2173)
@@ -19,7 +19,7 @@
 
 \usage{
 ordihull(ord, groups, display = "sites", draw = c("lines","polygon", "none"),
-         show.groups, label = FALSE,  ...)
+         col = NULL, show.groups, label = FALSE,  ...)
 ordiellipse(ord, groups, display="sites", kind = c("sd","se"), conf,
          draw = c("lines","polygon", "none"), w = weights(ord, display),
          col = NULL, show.groups, label = FALSE, ...)
@@ -43,6 +43,13 @@
     non-transparent. With \code{none} nothing is drawn, but the
     function returns the \code{\link{invisible}} plotting data.}
 
+  \item{col}{Colour of hull or ellipse lines (if \code{draw = "lines"})
+    or their fills (if \code{draw = "polygon"}) in \code{ordihull} and
+    \code{ordiellipse}.  When \code{draw = "polygon"}, the colour of
+    bordering lines can be set with argument \code{border} of the
+    \code{\link{polygon}} function. For other functions the effect
+    depends on the underlining functions this argument is passed to.}
+
   \item{show.groups}{Show only given groups. This can be a vector, or
     \code{TRUE} if you want to show items for which condition is
     \code{TRUE}. This argument makes it possible to use different
@@ -69,10 +76,6 @@
   \item{cluster}{Result of hierarchic cluster analysis, such as
     \code{\link{hclust}} or \code{\link[cluster]{agnes}}.}
 
-  \item{col}{Colour of ellipses or ellipse fills in
-    \code{ordiellipse}. For other functions the effect depends on the
-    underlining functions this argument is passed to.}
-
   \item{prune}{Number of upper level hierarchies removed from the
     dendrogram. If \code{prune} \eqn{>0}, dendrogram will be
     disconnected.}



More information about the Vegan-commits mailing list