[Vegan-commits] r2239 - in pkg/vegan: R inst man
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Tue Jul 31 13:43:17 CEST 2012
Author: jarioksa
Date: 2012-07-31 13:43:17 +0200 (Tue, 31 Jul 2012)
New Revision: 2239
Modified:
pkg/vegan/R/plot.envfit.R
pkg/vegan/inst/ChangeLog
pkg/vegan/man/envfit.Rd
Log:
plot.envfit() gained argument 'labels' to change the default labels.
Modified: pkg/vegan/R/plot.envfit.R
===================================================================
--- pkg/vegan/R/plot.envfit.R 2012-07-31 11:43:09 UTC (rev 2238)
+++ pkg/vegan/R/plot.envfit.R 2012-07-31 11:43:17 UTC (rev 2239)
@@ -1,11 +1,30 @@
`plot.envfit` <-
- function (x, choices = c(1, 2), arrow.mul, at = c(0, 0),
+ function (x, choices = c(1, 2), labels, arrow.mul, at = c(0, 0),
axis = FALSE, p.max = NULL, col = "blue", bg, add = TRUE, ...)
{
formals(arrows) <- c(formals(arrows), alist(... = ))
## get labels
labs <- list("v" = rownames(x$vectors$arrows),
"f" = rownames(x$factors$centroids))
+ ## Change labels if user so wishes
+ if (!missing(labels)) {
+ ## input list of "vectors" and/or "factors"
+ if (is.list(labels)) {
+ if (!is.null(labs$v) && !is.null(labels$vectors))
+ labs$v <- labels$vectors
+ if (!is.null(labs$f) && !is.null(labels$factors))
+ labs$f <- labels$factors
+ } else {
+ ## input vector: either vectors or factors must be NULL,
+ ## and the existing set of labels is replaced
+ if (!is.null(labs$v) && !is.null(labs$f))
+ stop("needs a list with both 'vectors' and 'factors' labels")
+ if (!is.null(labs$v))
+ labs$v <- labels
+ else
+ labs$f <- labels
+ }
+ }
vect <- NULL
if (!is.null(p.max)) {
if (!is.null(x$vectors)) {
Modified: pkg/vegan/inst/ChangeLog
===================================================================
--- pkg/vegan/inst/ChangeLog 2012-07-31 11:43:09 UTC (rev 2238)
+++ pkg/vegan/inst/ChangeLog 2012-07-31 11:43:17 UTC (rev 2239)
@@ -4,8 +4,9 @@
Version 2.1-18 (opened July 30, 2012)
- * envift: got labels() method that returns the labels used in
- plot().
+ * envift: the plot() method gained argument 'labels' to change the
+ default labels. The default labels are displayed with the new
+ labels() function.
Version 2.1-17 (closed July 30, 2012)
Modified: pkg/vegan/man/envfit.Rd
===================================================================
--- pkg/vegan/man/envfit.Rd 2012-07-31 11:43:09 UTC (rev 2238)
+++ pkg/vegan/man/envfit.Rd 2012-07-31 11:43:17 UTC (rev 2239)
@@ -19,8 +19,8 @@
\method{envfit}{default}(ord, env, permutations = 999, strata, choices=c(1,2),
display = "sites", w = weights(ord), na.rm = FALSE, ...)
\method{envfit}{formula}(formula, data, ...)
-\method{plot}{envfit}(x, choices = c(1,2), arrow.mul, at = c(0,0), axis = FALSE,
- p.max = NULL, col = "blue", bg, add = TRUE, ...)
+\method{plot}{envfit}(x, choices = c(1,2), labels, arrow.mul, at = c(0,0),
+ axis = FALSE, p.max = NULL, col = "blue", bg, add = TRUE, ...)
\method{scores}{envfit}(x, display, choices, ...)
vectorfit(X, P, permutations = 0, strata, w, ...)
factorfit(X, P, permutations = 0, strata, w, ...)
@@ -47,6 +47,13 @@
\code{na.rm = TRUE}.}
\item{x}{A result object from \code{envfit}.}
\item{choices}{Axes to plotted.}
+ \item{labels}{Change plotting labels. The argument should be a list
+ with elements \code{vectors} and \code{factors} which give the new
+ plotting labels. If either of these elements is omitted, the
+ default labels will be used. If there is only one type of elements
+ (only \code{vectors} or only \code{factors}), the labels can be
+ given as vector. The default labels can be displayed with
+ \code{labels} command.}
\item{arrow.mul}{Multiplier for vector lengths. The arrows are
automatically scaled similarly as in \code{\link{plot.cca}} if this
is not given and \code{add = TRUE}.}
@@ -212,6 +219,10 @@
ordispider(ord, Moisture, col="skyblue")
points(ord, display = "sites", col = as.numeric(Moisture), pch=16)
plot(fit, cex=1.2, axis=TRUE, bg = rgb(1, 1, 1, 0.5))
+## Use shorter labels for factor centroids
+labels(fit)
+plot(ord)
+plot(fit, labels=list(factors = paste0("M", c(1,2,4,5))), bg = rgb(1,1,0,0.5))
}
\keyword{multivariate }
\keyword{aplot}
More information about the Vegan-commits
mailing list