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

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Tue Apr 10 12:58:13 CEST 2012


Author: jarioksa
Date: 2012-04-10 12:58:13 +0200 (Tue, 10 Apr 2012)
New Revision: 2127

Modified:
   pkg/vegan/R/msoplot.R
   pkg/vegan/inst/ChangeLog
   pkg/vegan/man/mso.Rd
Log:
Merge branch 'master' into r-forge-svn-local

Modified: pkg/vegan/R/msoplot.R
===================================================================
--- pkg/vegan/R/msoplot.R	2012-04-04 20:14:12 UTC (rev 2126)
+++ pkg/vegan/R/msoplot.R	2012-04-10 10:58:13 UTC (rev 2127)
@@ -1,5 +1,5 @@
 `msoplot` <-
-    function (x, alpha = 0.05, explained = FALSE, ...) 
+    function (x, alpha = 0.05, explained = FALSE, ylim = NULL, ...) 
 {
     object.cca <- x
     if (is.data.frame(object.cca$vario)) {
@@ -17,19 +17,18 @@
                    "Residual variance", "Explained variance", "Conditioned variance")
         ci.lab <- "C.I. for total variance"
         sign.lab <- if(hasSig) "Sign. autocorrelation" else NULL
-        ## You should not change par, or at least you must put
-        ## back the old values when exiting:
-        ## op <- par(omi = c(0.5, 0.5, 0, 0))
-        ## on.exit(par(op))
-        ##par(omi = c(0.5, 0.5, 0, 0))
         if (is.numeric(object$CCA$rank)) {
             if (!explained) 
                 b <- b - 1
             if (is.numeric(object$vario$se)) 
                 b <- b - 1
-            plot(vario$Dist, vario$All, type = "n", lty = 1, 
-                 pch = 3, xlab = "Distance", ylab = "Variance", 
-                 ylim = c(0, ymax), cex.lab = 1.2, ...)
+            figmat <- cbind(vario$All + z * vario$se,
+                            vario$All - z * vario$se,
+                            vario$Sum,
+                            vario[, 6:(b + 3)])
+            matplot(vario$Dist, cbind(0,figmat), type = "n",
+                    xlab = "Distance", ylab = "Variance",
+                    ylim = ylim, ...)
             lines(vario$Dist, vario$All + z * vario$se, lty = 1, ...)
             lines(vario$Dist, vario$All - z * vario$se, lty = 1, ...)
             lines(vario$Dist, vario$Sum, type = "b", lty = 2, 
@@ -39,24 +38,22 @@
                    lty=c(c(1,2,1,1,1)[2:b], 1, if(hasSig) NA),
                    pch=c(3, (6:(b+3))-6, NA, if(hasSig) 15)
                    )
-            for (i in 6:(b + 3)) {
-                lines(vario$Dist, vario[, i], type = "b", lty = 1, 
-                      pch = i - 6, ...)
-            }
-            text(x = c(vario$Dist), y = rep(0, length(vario$Dist)), 
+            matlines(vario$Dist, figmat[,-c(1:3)], type = "b", lty = 1,
+                     pch = 6:(b+3)-6, ...)
+            text(x = c(vario$Dist), y = par("usr")[3], pos = 3, 
                  label = c(vario$n), cex = 0.8, ...)
-            lines(x = rep(max(object$H)/2, 2), y = c(-10, ymax + 
-                                               10), lty = 3, ...)
+            abline(v = max(object$H/2), lty = 3, ...)
         }
         else {
+            if (is.null(ylim))
+                ylim <- c(0, ymax)
             plot(vario$Dist, vario$All, type = "b", lty = 1, 
-                 pch = 0, xlab = "Distance", ylab = "Variance", 
-                 ylim = c(0, ymax), cex.lab = 1.2, ...)
-            lines(c(0, 10), rep(object$tot.chi, 2), lty = 5, ...)
-            text(x = c(vario$Dist), y = rep(0, length(vario$Dist)), 
+                 pch = 0, xlab = "Distance", ylab = "Variance",
+                 ylim = ylim, ...)
+            abline(h = object$tot.chi, lty = 5, ...)
+            text(x = c(vario$Dist), y = par("usr")[3], pos = 3, 
                  label = c(vario$n), cex = 0.8)
-            lines(x = rep(max(object$H)/2, 2), y = c(-10, ymax + 
-                                               10), lty = 3, ...)
+            abline(v = max(object$H)/2, lty = 3, ...)
             legend("topleft",
                    c("Total variance","Global variance estimate",
                      if(hasSig) "Sign. autocorrelation"),

Modified: pkg/vegan/inst/ChangeLog
===================================================================
--- pkg/vegan/inst/ChangeLog	2012-04-04 20:14:12 UTC (rev 2126)
+++ pkg/vegan/inst/ChangeLog	2012-04-10 10:58:13 UTC (rev 2127)
@@ -15,6 +15,13 @@
 	to anosim, mrpp, simper (where this worst) and adonis (where this
 	was already analysed by Marti Anderson when introducing the
 	method).
+
+	* msoplot: expose 'ylim' as an argument. Previously, 'ylim' was
+	set internally and user could not change it setting, although
+	y-axis maximum was sometimes so low that standard errors were
+	outside the plot, and legend covered lines. The default setting of
+	'ylim' was improved, and the function follows R idiom more
+	closely. Reported in a private email to J.O. by Ricardo Pita.
 	
 Version 2.1-13 (closed March 9, 2012)
 

Modified: pkg/vegan/man/mso.Rd
===================================================================
--- pkg/vegan/man/mso.Rd	2012-04-04 20:14:12 UTC (rev 2126)
+++ pkg/vegan/man/mso.Rd	2012-04-10 10:58:13 UTC (rev 2127)
@@ -14,7 +14,7 @@
 
 \usage{
 mso(object.cca, object.xy, grain = 1, round.up = FALSE, permutations = FALSE)
-msoplot(x, alpha = 0.05, explained = FALSE, ...)
+msoplot(x, alpha = 0.05, explained = FALSE, ylim = NULL, ...)
 }
 \arguments{
   \item{object.cca}{ An object of class cca, created by the \code{\link{cca}} or
@@ -39,6 +39,7 @@
     classes.} 
   \item{explained}{ If false, suppresses the plotting of the variogram
     of explained variance.}
+  \item{ylim}{Limits for y-axis.}
   \item{\dots}{Other arguments passed to functions.}
 }
 \details{



More information about the Vegan-commits mailing list