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

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Tue May 22 22:55:21 CEST 2012


Author: jarioksa
Date: 2012-05-22 22:55:21 +0200 (Tue, 22 May 2012)
New Revision: 2176

Modified:
   pkg/vegan/R/ordiellipse.R
   pkg/vegan/R/ordihull.R
   pkg/vegan/inst/ChangeLog
   pkg/vegan/man/ordihull.Rd
Log:
ordihull & ordiellipse default to semitransparent fill colour with draw = 'polygon'

Modified: pkg/vegan/R/ordiellipse.R
===================================================================
--- pkg/vegan/R/ordiellipse.R	2012-05-22 15:53:27 UTC (rev 2175)
+++ pkg/vegan/R/ordiellipse.R	2012-05-22 20:55:21 UTC (rev 2176)
@@ -1,7 +1,7 @@
-"ordiellipse" <-
+`ordiellipse` <-
     function (ord, groups, display = "sites", kind = c("sd", "se"),
               conf, draw = c("lines", "polygon", "none"),
-              w = weights(ord, display), col = NULL, 
+              w = weights(ord, display), col = NULL, alpha = 127,
               show.groups, label = FALSE,  ...)
 {
     weights.default <- function(object, ...) NULL
@@ -19,7 +19,10 @@
         w <- rep(1, nrow(pts))
     if (is.null(w))
         w <- rep(1, nrow(pts))
-     if (!missing(show.groups)) {
+    ## make semitransparent fill
+    if (draw == "polygon" && !is.null(col))
+        col <- rgb(t(col2rgb(col)), alpha = alpha, maxColorValue = 255)
+    if (!missing(show.groups)) {
         take <- groups %in% show.groups
         pts <- pts[take, , drop = FALSE]
         groups <- groups[take]

Modified: pkg/vegan/R/ordihull.R
===================================================================
--- pkg/vegan/R/ordihull.R	2012-05-22 15:53:27 UTC (rev 2175)
+++ pkg/vegan/R/ordihull.R	2012-05-22 20:55:21 UTC (rev 2176)
@@ -1,7 +1,7 @@
 `ordihull` <-
     function (ord, groups, display = "sites",
               draw = c("lines", "polygon", "none"),
-              col = NULL, show.groups, label = FALSE, ...)
+              col = NULL, alpha = 127, show.groups, label = FALSE, ...)
 {
     draw <- match.arg(draw)
     ## Internal function to find the polygon centre
@@ -15,7 +15,9 @@
         yc <- sum((x[-n, 2] + x[-1, 2]) * xy)/A/6
         c(xc, yc)
     }
-
+    ## Make semitransparent fill colour
+    if (draw == "polygon" && !is.null(col))
+        col <- rgb(t(col2rgb(col)), alpha = alpha, maxColorValue = 255)
     pts <- scores(ord, display = display, ...)
     if (!missing(show.groups)) {
         take <- groups %in% show.groups

Modified: pkg/vegan/inst/ChangeLog
===================================================================
--- pkg/vegan/inst/ChangeLog	2012-05-22 15:53:27 UTC (rev 2175)
+++ pkg/vegan/inst/ChangeLog	2012-05-22 20:55:21 UTC (rev 2176)
@@ -4,6 +4,10 @@
 
 Version 2.1-16 (opened May 11, 2012)
 
+	* ordihull, ordiellipse: defaults to use semitransparent fill
+	colour with 'draw = "polygon"', and gain argument 'alpha' to set
+	the transparency. 
+
 	* 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

Modified: pkg/vegan/man/ordihull.Rd
===================================================================
--- pkg/vegan/man/ordihull.Rd	2012-05-22 15:53:27 UTC (rev 2175)
+++ pkg/vegan/man/ordihull.Rd	2012-05-22 20:55:21 UTC (rev 2176)
@@ -19,10 +19,10 @@
 
 \usage{
 ordihull(ord, groups, display = "sites", draw = c("lines","polygon", "none"),
-         col = NULL, show.groups, label = FALSE,  ...)
+         col = NULL, alpha = 127, 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, ...)
+         col = NULL, alpha = 127, show.groups, label = FALSE, ...)
 ordispider(ord, groups, display="sites", w = weights(ord, display),
          show.groups, label = FALSE, ...)
 ordicluster(ord, cluster, prune = 0, display = "sites",
@@ -50,6 +50,13 @@
     \code{\link{polygon}} function. For other functions the effect
     depends on the underlining functions this argument is passed to.}
 
+  \item{alpha}{Transparency of the fill \code{col}our with \code{draw
+    = "polygon"} in \code{ordihull} and \code{ordiellipse}.  The
+    argument takes precedence over possible transparency definitions
+    of the colour. The value must be in range \eqn{0...255}, and low
+    values are more transparent.  Transparency is not available in all
+    graphics devices or file formats.}
+
   \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
@@ -181,7 +188,8 @@
 ordicluster(mod, hclust(vegdist(dune)), prune=3, col = "blue")
 plot(mod, type="n", display = "sites")
 text(mod, display="sites", labels = as.character(Management))
-pl <- ordiellipse(mod, Management, kind="se", conf=0.95, lwd=2, col="blue")
+pl <- ordiellipse(mod, Management, kind="se", conf=0.95, lwd=2, draw = "polygon", 
+  col="skyblue", border = "blue")
 summary(pl)
 }
 \keyword{aplot }



More information about the Vegan-commits mailing list