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

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Wed Dec 1 15:15:47 CET 2010


Author: jarioksa
Date: 2010-12-01 15:15:46 +0100 (Wed, 01 Dec 2010)
New Revision: 1385

Modified:
   pkg/vegan/R/plot.procrustes.R
   pkg/vegan/inst/ChangeLog
   pkg/vegan/man/procrustes.Rd
Log:
plot.procrustes gains 'type' and 'to.target' to set the direction of the arrows

Modified: pkg/vegan/R/plot.procrustes.R
===================================================================
--- pkg/vegan/R/plot.procrustes.R	2010-12-01 12:40:19 UTC (rev 1384)
+++ pkg/vegan/R/plot.procrustes.R	2010-12-01 14:15:46 UTC (rev 1385)
@@ -1,9 +1,16 @@
 "plot.procrustes" <-
-    function (x, kind = 1, choices = c(1,2), xlab, ylab, main, ar.col = "blue", 
-          len = 0.05,  ...) 
+    function (x, kind = 1, choices = c(1,2), to.target = TRUE,
+              type = "p", xlab, ylab, main, ar.col = "blue",
+              len = 0.05, cex = 0.7,  ...) 
 {
-    Yrot <- x$Yrot[, choices]
-    X <- x$X[, choices]
+    type <- match.arg(type, c("points", "text", "none"))
+    if (to.target) {
+        tails <- x$Yrot[, choices]
+        heads <- x$X[, choices]
+    } else {
+        tails <- x$X[, choices]
+        heads <- x$Yrot[, choices]
+    }
     if (missing(main)) 
         main <- "Procrustes errors"
     if (kind <= 1) {
@@ -12,12 +19,12 @@
             xlab <- paste("Dimension", choices[1])
         if (missing(ylab)) 
             ylab <- paste("Dimension", choices[2])
-        xrange <- range(Yrot[, 1], X[, 1])
-        yrange <- range(Yrot[, 2], X[, 2])
+        xrange <- range(tails[, 1], heads[, 1])
+        yrange <- range(tails[, 2], heads[, 2])
         plot(xrange, yrange, xlab = xlab, ylab = ylab, main = main, 
-            type = "n", asp = 1, ...)
+             type = "n", asp = 1, ...)
         if (kind > 0) {
-	        abline(v = 0, lty = 2)
+            abline(v = 0, lty = 2)
             abline(h = 0, lty = 2)
             if (ncol(x$rotation) == 2) {
                 ## Draw rotated axes only if they visibly differ from
@@ -41,13 +48,18 @@
                     text(tmp[2,choices[1]], tmp[2,choices[2]], as.character(k))
                 }
             }
-            points(Yrot, ...)
-            ow <- options(warn = -1)
-            arrows(Yrot[, 1], Yrot[, 2], X[, 1], X[, 2], col = ar.col, 
-                len = len, ...)
-            options(ow)
+            if (type != "none") {
+                ow <- options(warn = -1)
+                arrows(tails[, 1], tails[, 2], heads[, 1], heads[, 2],
+                       col = ar.col, len = len, ...)
+                options(ow)
+                if (type == "text" && !is.null(rownames(tails)))
+                    ordilabel(tails, cex = cex, ...)
+                else
+                    points(tails, cex = cex, ...)
+            }
         }
-        out <- list(heads = X, points = Yrot)
+        out <- list(heads = heads, points = tails)
         class(out) <- "ordiplot"
     }
     else if (kind == 2) {
@@ -58,7 +70,7 @@
         res <- residuals(x)
         q <- quantile(res)
         plot(res, type = "h", xlab = xlab, ylab = ylab, main = main, 
-            ...)
+             ...)
         abline(h = q[2:4], lty = c(2, 1, 2))
         out <- list(sites = cbind(seq(along = res), res))
         class(out) <- "ordiplot"

Modified: pkg/vegan/inst/ChangeLog
===================================================================
--- pkg/vegan/inst/ChangeLog	2010-12-01 12:40:19 UTC (rev 1384)
+++ pkg/vegan/inst/ChangeLog	2010-12-01 14:15:46 UTC (rev 1385)
@@ -7,6 +7,10 @@
 	* prc: got back the formula interface and with that the na.action
 	lost in r1356 (9 Nov, 2010).
 
+	* plot.procrustes: user can select the direction of the arrow with
+	argument 'to.target', and the 'type' of the plot. With 'type =
+	"text"', ordilabel() is used to mark the tails of the arrows.
+
 Version 1.18-17 (closed December 1, 2010)
 	
 	* predict.procrustes: gained 'truemean' so that new points can be

Modified: pkg/vegan/man/procrustes.Rd
===================================================================
--- pkg/vegan/man/procrustes.Rd	2010-12-01 12:40:19 UTC (rev 1384)
+++ pkg/vegan/man/procrustes.Rd	2010-12-01 14:15:46 UTC (rev 1385)
@@ -22,8 +22,9 @@
 \usage{
 procrustes(X, Y, scale = TRUE, symmetric = FALSE, scores = "sites", ...)
 \method{summary}{procrustes}(object, digits = getOption("digits"), ...)
-\method{plot}{procrustes}(x, kind=1, choices=c(1,2), xlab, ylab, main,
-     ar.col = "blue", len=0.05, ...)
+\method{plot}{procrustes}(x, kind=1, choices=c(1,2), to.target = TRUE, 
+    type = "p", xlab, ylab, main, ar.col = "blue", len=0.05, 
+    cex = 0.7, ...)
 \method{points}{procrustes}(x, display = c("target", "rotated"), ...)
 \method{text}{procrustes}(x, display = c("target", "rotated"), labels, ...)
 \method{lines}{procrustes}(x, type = c("segments", "arrows"), choices = c(1, 2), ...)  
@@ -54,8 +55,13 @@
   \item{main}{Plot title, if default unacceptable.}
   \item{display}{Show only the \code{"target"} or \code{"rotated"}
     matrix as points.}
-  \item{type}{Combine \code{target} and \code{rotated} points with line
-    segments or arrows.}
+  \item{to.target}{Draw arrows to point to target.}
+  \item{type}{The type of plot drawn. In \code{plot}, the \code{type}
+    can be \code{"points"} or \code{"text"} to select the marker for
+    the tail of the arrow, or \code{"none"} for drawing an empty
+    plot. In \code{lines} the \code{type} selects either
+    \code{\link{arrows}} or line \code{\link{segments}} to connect
+    target and rotated configuration.}
   \item{truemean}{Use the original range of target matrix instead of
     centring the fitted values. Function \code{plot.procrustes} needs
     \code{truemean = FALSE}.}
@@ -70,6 +76,7 @@
   \item{len}{Width of the arrow head.}
   \item{labels}{Character vector of text labels. Rownames of the result 
     object are used as default.}
+  \item{cex}{Character expansion for points or text.}
   \item{...}{Other parameters passed to functions. In \code{procrustes}
     and \code{protest} parameters are passed to \code{\link{scores}}, in
     graphical functions to underlying graphical functions.}
@@ -93,26 +100,26 @@
   \code{\link{scores}}, \code{\link{scores.cca}} etc. so that you can
   specify arguments such as \code{scaling}. 
 
-  Function \code{plot} plots a \code{procrustes}
-  object and  returns invisibly an \code{ordiplot} object so that
-  function \code{\link{identify.ordiplot}} can be used for identifying
+  Function \code{plot} plots a \code{procrustes} object and returns
+  invisibly an \code{ordiplot} object so that function
+  \code{\link{identify.ordiplot}} can be used for identifying
   points. The items in the \code{ordiplot} object are called
-  \code{heads} and \code{points} with \code{kind=1} (ordination diagram)
-  and \code{sites} with \code{kind=2} (residuals).  In ordination
-  diagrams, the arrow heads point to the target configuration, which may
-  be either logical or illogical. Target and original rotated axes are
-  shown as cross hairs in two-dimensional Procrustes analysis, and with
-  a higher number of dimensions, the rotated axes are projected onto
-  plot with their scaled and centred range. Function
-  \code{plot} passes
-  parameters to underlying plotting functions.  For full control of
-  plots, you can draw the axes using \code{plot} with \code{kind = 0},
-  and then add items with \code{points} or \code{lines}.  These
-  functions pass all parameters to the underlying functions so that you
-  can select the plotting characters, their size, colours etc., or you
-  can select the width, colour and type of line \code{\link{segments}} or
-  arrows, or you can select the orientation and head width of
-  \code{\link{arrows}}.
+  \code{heads} and \code{points} with \code{kind=1} (ordination
+  diagram) and \code{sites} with \code{kind=2} (residuals).  In
+  ordination diagrams, the arrow heads point to the target
+  configuration if \code{to.target = TRUE}, and to rotated
+  configuration if \code{to.target = FALSE}.  Target and original
+  rotated axes are shown as cross hairs in two-dimensional Procrustes
+  analysis, and with a higher number of dimensions, the rotated axes
+  are projected onto plot with their scaled and centred
+  range. Function \code{plot} passes parameters to underlying plotting
+  functions.  For full control of plots, you can draw the axes using
+  \code{plot} with \code{kind = 0}, and then add items with
+  \code{points} or \code{lines}.  These functions pass all parameters
+  to the underlying functions so that you can select the plotting
+  characters, their size, colours etc., or you can select the width,
+  colour and type of line \code{\link{segments}} or arrows, or you can
+  select the orientation and head width of \code{\link{arrows}}.
 
   Function \code{residuals} returns the pointwise
   residuals, and \code{fitted} the fitted values, either centred to zero



More information about the Vegan-commits mailing list