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

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Thu Sep 23 12:47:20 CEST 2010


Author: jarioksa
Date: 2010-09-23 12:47:20 +0200 (Thu, 23 Sep 2010)
New Revision: 1313

Modified:
   pkg/vegan/R/ordiellipse.R
   pkg/vegan/R/ordilabel.R
   pkg/vegan/inst/ChangeLog
   pkg/vegan/man/ordihull.Rd
   pkg/vegan/man/ordilabel.Rd
Log:
use border colour for labels in ordiellipse polygons

Modified: pkg/vegan/R/ordiellipse.R
===================================================================
--- pkg/vegan/R/ordiellipse.R	2010-09-23 10:29:25 UTC (rev 1312)
+++ pkg/vegan/R/ordiellipse.R	2010-09-23 10:47:20 UTC (rev 1313)
@@ -1,7 +1,7 @@
 "ordiellipse" <-
     function (ord, groups, display = "sites", kind = c("sd", "se"),
               conf, draw = c("lines", "polygon", "none"),
-              w = weights(ord, display),
+              w = weights(ord, display), col = NULL, 
               show.groups, label = FALSE,  ...)
 {
     weights.default <- function(object, ...) NULL
@@ -43,9 +43,12 @@
             else t <- sqrt(qchisq(conf, 2))
             xy <- veganCovEllipse(mat$cov, mat$center, t)
             if (draw == "lines")
-                ordiArgAbsorber(xy, FUN = lines, ...)
+                ordiArgAbsorber(xy, FUN = lines,
+                                col = if(is.null(col)) par("fg") else col,
+                                ...)
             else if (draw == "polygon") 
-                ordiArgAbsorber(xy[, 1], xy[, 2], FUN = polygon, ...)
+                ordiArgAbsorber(xy[, 1], xy[, 2], col = col, FUN = polygon,
+                                ...)
             if (label && draw != "none") {
                 cntrs <- rbind(cntrs, mat$center)
                 names <- c(names, is)
@@ -56,10 +59,11 @@
     }
     if (label && draw != "none") {
         if (draw == "lines")
-            ordiArgAbsorber(cntrs[,1], cntrs[,2], labels=names, 
+            ordiArgAbsorber(cntrs[,1], cntrs[,2], labels=names, col = col,  
                             FUN = text, ...)
-        else
-            ordiArgAbsorber(cntrs, labels = names, FUN = ordilabel, ...)
+        else 
+            ordiArgAbsorber(cntrs, labels = names, col = NULL,
+                            FUN = ordilabel, ...)
     }
     class(res) <- "ordiellipse"
     invisible(res)

Modified: pkg/vegan/R/ordilabel.R
===================================================================
--- pkg/vegan/R/ordilabel.R	2010-09-23 10:29:25 UTC (rev 1312)
+++ pkg/vegan/R/ordilabel.R	2010-09-23 10:47:20 UTC (rev 1313)
@@ -1,6 +1,7 @@
 `ordilabel` <-
     function(x, display, labels, choices = c(1,2), priority,
-             cex = 0.8, fill = "white", border = NULL,  ...)
+             cex = 0.8, fill = "white", border = NULL, col = NULL,
+             ...)
 {
     if (missing(display))
         display <- "sites"
@@ -16,10 +17,15 @@
     ex <- strheight("x", cex = cex, ...)
     w <- (strwidth(labels, cex=cex,...) + em/1.5)/2
     h <- (strheight(labels, cex = cex, ...) + ex/1.5)/2
+    if (is.null(col))
+        if (!is.null(border))
+            col <- border
+        else
+            col <- par("fg")
     for (i in 1:nrow(x)) {
         polygon(x[i,1] + c(-1,1,1,-1)*w[i], x[i,2] + c(-1,-1,1,1)*h[i],
                 col = fill, border = border)
-        text(x[i,1], x[i,2], labels = labels[i], cex = cex, ...)
+        text(x[i,1], x[i,2], labels = labels[i], cex = cex, col = col, ...)
     }
     invisible(x)
 }

Modified: pkg/vegan/inst/ChangeLog
===================================================================
--- pkg/vegan/inst/ChangeLog	2010-09-23 10:29:25 UTC (rev 1312)
+++ pkg/vegan/inst/ChangeLog	2010-09-23 10:47:20 UTC (rev 1313)
@@ -4,6 +4,15 @@
 
 Version 1.18-12 (opened September 17, 2010)
 
+	* ordilabel: gained argument 'col' to set the text colour of the
+	labels separately from 'border' (default action is to use 'border'
+	colour). 
+
+	* ordiellipse: gained argument 'col'. For draw = "lines" this
+	works similarly as previously when 'col' was passed on. For draw =
+	"polygon" 'col' sets only the polygon fill, and the text of the
+	labels will use the colour of the border or of the foreground.
+
 	* ordiR2step: gained argument 'direction = c("both", "response")',
 	and iwth "both" gives also adjusted R2 when dropping terms. I have
 	not yet seen a case where a terms is dropped. Abandoned dangerous

Modified: pkg/vegan/man/ordihull.Rd
===================================================================
--- pkg/vegan/man/ordihull.Rd	2010-09-23 10:29:25 UTC (rev 1312)
+++ pkg/vegan/man/ordihull.Rd	2010-09-23 10:47:20 UTC (rev 1313)
@@ -27,7 +27,7 @@
          show.groups, label = FALSE,  ...)
 ordiellipse(ord, groups, display="sites", kind = c("sd","se"), conf,
          draw = c("lines","polygon", "none"), w = weights(ord, display),
-         show.groups, label = FALSE, ...)
+         show.groups, col = NULL, label = FALSE, ...)
 ordispider(ord, groups, display="sites", w = weights(ord, display),
          show.groups, label = FALSE, ...)
 ordiarrows(ord, groups, levels, replicates, display = "sites",
@@ -83,7 +83,10 @@
     2df. }
   \item{cluster}{Result of hierarchic cluster analysis, such as
     \code{\link{hclust}} or \code{\link[cluster]{agnes}}.}
-  \item{lty, col, lwd}{Line type, line colour and line width used for 
+  \item{col}{Colour of ellipses or ellipse fills in \code{ordiellipse}
+    or lines in \code{ordigrid}.  For other functions the effect depends
+    on the underlining functions this argument is passed to.}
+  \item{lty, lwd}{Line type, line width used for 
     \code{level}s and \code{replicate}s in \code{ordigrid}.}
   \item{prune}{Number of upper level hierarchies removed from the
     dendrogram. If \code{prune} \eqn{>0}, dendrogram will be

Modified: pkg/vegan/man/ordilabel.Rd
===================================================================
--- pkg/vegan/man/ordilabel.Rd	2010-09-23 10:29:25 UTC (rev 1312)
+++ pkg/vegan/man/ordilabel.Rd	2010-09-23 10:47:20 UTC (rev 1313)
@@ -11,7 +11,7 @@
 
 \usage{
 ordilabel(x, display, labels, choices = c(1, 2), priority, cex = 0.8,
-    fill = "white", border = NULL, ...)
+    fill = "white", border = NULL, col = NULL, ...)
 }
 
 \arguments{
@@ -30,6 +30,8 @@
     of \code{\link{polygon}}).}
   \item{border}{The colour and visibility of the border of the label as
     defined in \code{\link{polygon}}).}
+  \item{col}{Text colour. Default \code{NULL} will give the value of
+    \code{border} or \code{par("fg")} if \code{border} is \code{NULL}.} 
   \item{\dots}{Other arguments (passed to \code{\link{text}}). }
 }
 



More information about the Vegan-commits mailing list