[Vegan-commits] r2215 - in pkg/vegan: R inst man tests/Examples

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Wed Jun 13 10:54:53 CEST 2012


Author: jarioksa
Date: 2012-06-13 10:54:53 +0200 (Wed, 13 Jun 2012)
New Revision: 2215

Modified:
   pkg/vegan/R/plot.envfit.R
   pkg/vegan/inst/ChangeLog
   pkg/vegan/man/envfit.Rd
   pkg/vegan/tests/Examples/vegan-Ex.Rout.save
Log:
plot.envfit gained argument 'bg' to set background colour of labels

Modified: pkg/vegan/R/plot.envfit.R
===================================================================
--- pkg/vegan/R/plot.envfit.R	2012-06-07 08:31:50 UTC (rev 2214)
+++ pkg/vegan/R/plot.envfit.R	2012-06-13 08:54:53 UTC (rev 2215)
@@ -1,6 +1,6 @@
 `plot.envfit` <-
     function (x, choices = c(1, 2), arrow.mul, at = c(0, 0),
-              axis = FALSE, p.max = NULL, col = "blue", add = TRUE, ...)
+              axis = FALSE, p.max = NULL, col = "blue", bg, add = TRUE, ...)
 {
     formals(arrows) <- c(formals(arrows), alist(... = ))
     vect <- NULL
@@ -86,11 +86,20 @@
     if (!is.null(vect)) {
         arrows(at[1], at[2], vect[, 1], vect[, 2], len = 0.05,
                col = col)
-        text(vtext, rownames(x$vectors$arrows), col = col, ...)
+        if (missing(bg))
+            text(vtext, rownames(x$vectors$arrows), col = col, ...)
+        else
+            ordilabel(vtext, labels = rownames(x$vectors$arrows),
+                      col = col, fill = bg, ...)
     }
     if (!is.null(x$factors)) {
-        text(x$factors$centroids[, choices, drop = FALSE],
-             rownames(x$factors$centroids), col = col, ...)
+        if (missing(bg))
+            text(x$factors$centroids[, choices, drop = FALSE],
+                 rownames(x$factors$centroids), col = col, ...)
+        else
+            ordilabel(x$factors$centroids[, choices, drop = FALSE],
+                      labels = rownames(x$factors$centroids),
+                      col = col, fill = bg, ...)
     }
     if (axis && !is.null(vect)) {
         axis(3, at = ax + at[1], labels = c(maxarr, 0, maxarr),

Modified: pkg/vegan/inst/ChangeLog
===================================================================
--- pkg/vegan/inst/ChangeLog	2012-06-07 08:31:50 UTC (rev 2214)
+++ pkg/vegan/inst/ChangeLog	2012-06-13 08:54:53 UTC (rev 2215)
@@ -4,6 +4,9 @@
 
 Version 2.1-16 (opened May 11, 2012)
 
+	* envfit: plot() gained new argument 'bg' that triggers labelling
+	with ordilabel() using the colour given in 'bg' as the background.
+
 	* simper: added parallel processing for permutation tests in
 	accordance with other vegan functions and with similar user
 	interface. The code was developed by Eduard Szöcs in

Modified: pkg/vegan/man/envfit.Rd
===================================================================
--- pkg/vegan/man/envfit.Rd	2012-06-07 08:31:50 UTC (rev 2214)
+++ pkg/vegan/man/envfit.Rd	2012-06-13 08:54:53 UTC (rev 2215)
@@ -19,7 +19,7 @@
    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", add = TRUE, ...)
+    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, ...)
@@ -57,6 +57,9 @@
     variables.  You must calculate \eqn{P} values with setting
     \code{permutations} to use this option. }
   \item{col}{Colour in plotting.}
+  \item{bg}{Background colour for labels. If \code{bg} is set, the
+    labels are displayed with \code{\link{ordilabel}} instead of
+    \code{text}. See Examples for using semitransparent background.}
   \item{add}{Results added to an existing ordination plot.}
   \item{strata}{An integer vector or factor specifying the strata for
     permutation. If supplied, observations are permuted only within the
@@ -196,7 +199,9 @@
 fit <- envfit(ord, varechem, perm = 999, display = "lc")
 plot(fit, p.max = 0.05, col = "red")
 ## Class variables, formula interface, and displaying the
-## inter-class variability with `ordispider'
+## inter-class variability with `ordispider', and semitransparent
+## white background for labels (semitransparent colours are not
+## supported by all graphics devices)
 data(dune)
 data(dune.env)
 attach(dune.env)
@@ -205,7 +210,7 @@
 plot(ord, type = "n")
 ordispider(ord, Moisture, col="skyblue")
 points(ord, display = "sites", col = as.numeric(Moisture), pch=16)
-plot(fit, cex=1.2, axis=TRUE)
+plot(fit, cex=1.2, axis=TRUE, bg = rgb(1, 1, 1, 0.5))
 }
 \keyword{multivariate }
 \keyword{aplot}

Modified: pkg/vegan/tests/Examples/vegan-Ex.Rout.save
===================================================================
--- pkg/vegan/tests/Examples/vegan-Ex.Rout.save	2012-06-07 08:31:50 UTC (rev 2214)
+++ pkg/vegan/tests/Examples/vegan-Ex.Rout.save	2012-06-13 08:54:53 UTC (rev 2215)
@@ -1,8 +1,8 @@
 
-R version 2.15.0 (2012-03-30)
+R Under development (unstable) (2012-06-11 r59557) -- "Unsuffered Consequences"
 Copyright (C) 2012 The R Foundation for Statistical Computing
 ISBN 3-900051-07-0
-Platform: x86_64-apple-darwin9.8.0/x86_64 (64-bit)
+Platform: x86_64-unknown-linux-gnu (64-bit)
 
 R is free software and comes with ABSOLUTELY NO WARRANTY.
 You are welcome to redistribute it under certain conditions.
@@ -154,14 +154,14 @@
 > plot(ef)
 > ordisurf(mod ~ pH, varechem, knots = 1, add = TRUE)
 Loading required package: mgcv
-This is mgcv 1.7-13. For overview type 'help("mgcv-package")'.
+This is mgcv 1.7-17. For overview type 'help("mgcv-package")'.
 
 Family: gaussian 
 Link function: identity 
 
 Formula:
 y ~ poly(x1, 1) + poly(x2, 1)
-<environment: 0x1023eddf0>
+<environment: 0x2622380>
 Total model degrees of freedom 3 
 
 GCV score: 0.0427924
@@ -2552,7 +2552,7 @@
 Run 17 stress 0.1825664 
 ... New best solution
 ... procrustes: rmse 0.0421789  max resid 0.1544029 
-Run 18 stress 0.1843199 
+Run 18 stress 0.1843201 
 Run 19 stress 0.2570123 
 Run 20 stress 0.3760596 
 > (fit <- envfit(ord, varechem, perm = 999))
@@ -2605,7 +2605,9 @@
 > fit <- envfit(ord, varechem, perm = 999, display = "lc")
 > plot(fit, p.max = 0.05, col = "red")
 > ## Class variables, formula interface, and displaying the
-> ## inter-class variability with `ordispider'
+> ## inter-class variability with `ordispider', and semitransparent
+> ## white background for labels (semitransparent colours are not
+> ## supported by all graphics devices)
 > data(dune)
 > data(dune.env)
 > attach(dune.env)
@@ -2614,7 +2616,7 @@
 > plot(ord, type = "n")
 > ordispider(ord, Moisture, col="skyblue")
 > points(ord, display = "sites", col = as.numeric(Moisture), pch=16)
-> plot(fit, cex=1.2, axis=TRUE)
+> plot(fit, cex=1.2, axis=TRUE, bg = rgb(1, 1, 1, 0.5))
 > 
 > 
 > 
@@ -3018,7 +3020,7 @@
 Run 17 stress 0.1825664 
 ... New best solution
 ... procrustes: rmse 0.0421789  max resid 0.1544029 
-Run 18 stress 0.1843199 
+Run 18 stress 0.1843201 
 Run 19 stress 0.2570123 
 Run 20 stress 0.3760596 
 > stressplot(mod)
@@ -4802,17 +4804,17 @@
 > vare.mds <- monoMDS(vare.dist)
 > with(varechem, ordisurf(vare.mds, Baresoil, bubble = 5))
 Loading required package: mgcv
-This is mgcv 1.7-13. For overview type 'help("mgcv-package")'.
+This is mgcv 1.7-17. For overview type 'help("mgcv-package")'.
 
 Family: gaussian 
 Link function: identity 
 
 Formula:
 y ~ s(x1, x2, k = knots)
-<environment: 0x1096c3750>
+<environment: 0x912fb60>
 
 Estimated degrees of freedom:
-6.4351  total = 7.435071 
+6.4351  total = 7.43507 
 
 GCV score: 144.1236
 > 
@@ -4825,7 +4827,7 @@
 
 Formula:
 y ~ s(x1, x2, k = knots)
-<environment: 0x109733fc8>
+<environment: 0x9a7e380>
 
 Estimated degrees of freedom:
 6.1039  total = 7.103853 
@@ -4837,13 +4839,13 @@
 > ## Get fitted values
 > calibrate(fit)
          1          2          3          4          5          6          7 
-22.0644614  6.0132251  3.6350483  4.1019742  9.0030989  5.9202601  8.6399184 
+22.0644615  6.0132250  3.6350484  4.1019743  9.0030990  5.9202602  8.6399182 
          8          9         10         11         12         13         14 
-11.0719303  0.6561781 35.2282118 10.4346331  7.2900018  5.5710617 24.6503110 
+11.0719302  0.6561783 35.2282116 10.4346331  7.2900019  5.5710617 24.6503109 
         15         16         17         18         19         20         21 
-18.8754521 29.7286543  5.6158934  9.5869716  3.2876267  2.7111721 10.7832857 
+18.8754520 29.7286540  5.6158934  9.5869715  3.2876268  2.7111723 10.7832857 
         22         23         24 
- 3.0020413  9.8128952  7.3656932 
+ 3.0020415  9.8128952  7.3656934 
 > 
 > ## Plot method
 > plot(fit, what = "contour")
@@ -4974,14 +4976,14 @@
 > ## Map of PCNMs in the sample plot
 > ordisurf(mite.xy, scores(pcnm1, choi=1), bubble = 4, main = "PCNM 1")
 Loading required package: mgcv
-This is mgcv 1.7-13. For overview type 'help("mgcv-package")'.
+This is mgcv 1.7-17. For overview type 'help("mgcv-package")'.
 
 Family: gaussian 
 Link function: identity 
 
 Formula:
 y ~ s(x1, x2, k = knots)
-<environment: 0x106156f78>
+<environment: 0x978d1e0>
 
 Estimated degrees of freedom:
 8.9275  total = 9.927492 
@@ -4994,7 +4996,7 @@
 
 Formula:
 y ~ s(x1, x2, k = knots)
-<environment: 0x109eccca0>
+<environment: 0x72ee4f8>
 
 Estimated degrees of freedom:
 7.7529  total = 8.75294 
@@ -5007,7 +5009,7 @@
 
 Formula:
 y ~ s(x1, x2, k = knots)
-<environment: 0x10a8d12e0>
+<environment: 0x97ecca8>
 
 Estimated degrees of freedom:
 8.8962  total = 9.89616 
@@ -5773,8 +5775,8 @@
 [2,] 0.1169579  0.9931369
 
 Translation of averages:
-             [,1]          [,2]
-[1,] 3.893131e-18 -9.725997e-18
+            [,1]         [,2]
+[1,] 1.79048e-17 9.246476e-19
 
 Scaling of target:
 [1] 0.6736868
@@ -7369,7 +7371,7 @@
 Run 17 stress 0.1825664 
 ... New best solution
 ... procrustes: rmse 0.0421789  max resid 0.1544029 
-Run 18 stress 0.1843199 
+Run 18 stress 0.1843201 
 Run 19 stress 0.2570123 
 Run 20 stress 0.3760596 
 > plot(ord, type = "t")
@@ -7539,14 +7541,14 @@
 > ## add fitted surface of diversity to the model
 > ordisurf(mod, diversity(dune), add = TRUE)
 Loading required package: mgcv
-This is mgcv 1.7-13. For overview type 'help("mgcv-package")'.
+This is mgcv 1.7-17. For overview type 'help("mgcv-package")'.
 
 Family: gaussian 
 Link function: identity 
 
 Formula:
 y ~ s(x1, x2, k = knots)
-<environment: 0x10b48ca98>
+<environment: 0x9a81d78>
 
 Estimated degrees of freedom:
 2  total = 3 
@@ -8026,7 +8028,7 @@
 > ### * <FOOTER>
 > ###
 > cat("Time elapsed: ", proc.time() - get("ptime", pos = 'CheckExEnv'),"\n")
-Time elapsed:  82.41 1.676 85.548 0 0 
+Time elapsed:  25.377 0.088 25.548 0 0 
 > grDevices::dev.off()
 null device 
           1 



More information about the Vegan-commits mailing list