[Analogue-commits] r172 - in pkg: . R inst man

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Thu May 27 00:14:28 CEST 2010


Author: gsimpson
Date: 2010-05-27 00:14:28 +0200 (Thu, 27 May 2010)
New Revision: 172

Modified:
   pkg/DESCRIPTION
   pkg/R/Stratiplot.R
   pkg/inst/ChangeLog
   pkg/man/Stratiplot.Rd
Log:
variable labels plotted as axis labels not strips by default, new argument 'strip', both in Stratiplot.default

Modified: pkg/DESCRIPTION
===================================================================
--- pkg/DESCRIPTION	2010-05-19 17:36:09 UTC (rev 171)
+++ pkg/DESCRIPTION	2010-05-26 22:14:28 UTC (rev 172)
@@ -3,7 +3,7 @@
 Title: Analogue and weighted averaging methods for palaeoecology
 Version: 0.6-24
 Date: $Date$
-Depends: R (>= 2.5.0), stats, graphics, vegan, lattice, MASS
+Depends: R (>= 2.5.0), stats, graphics, vegan, lattice, grid, MASS
 Author: Gavin L. Simpson, Jari Oksanen
 Maintainer: Gavin L. Simpson <gavin.simpson at ucl.ac.uk>
 Description: Fits Modern Analogue Technique and Weighted Averaging transfer 

Modified: pkg/R/Stratiplot.R
===================================================================
--- pkg/R/Stratiplot.R	2010-05-19 17:36:09 UTC (rev 171)
+++ pkg/R/Stratiplot.R	2010-05-26 22:14:28 UTC (rev 172)
@@ -11,7 +11,23 @@
                                  sort = c("none", "wa", "var"),
                                  svar = NULL,
                                  rev.sort = FALSE,
+                                 strip = FALSE,
                                  ...) {
+    ## inline function for custom axis
+    axis.VarLabs <- function(side, ...) {
+        if(isTRUE(all.equal(side, "top"))) {
+            M <- function(lims) min(lims) + (diff(lims) / 2)
+            xlim <- current.panel.limits()$xlim
+            panel.axis(side = side, outside = TRUE, at = M(xlim),
+                       tck = 1, line.col = "black",
+                       text.col = "black",
+                       labels = levels(sx$ind)[which.packet()],
+                       rot = 45)
+        } else {
+            axis.default(side = side, ...)
+        }
+    }
+
     ## process 'type'
     TYPE <- c("l","h","g","smooth","b","o", "poly","p")
     if(any(!(type %in% TYPE)))
@@ -53,7 +69,7 @@
     }
     ## plot parameters
     maxy <- max(y)
-    ylimits <- c(0 - (0.03*maxy), maxy + (0.03 * maxy))
+    ylimits <- c(0 - (0.03*maxy), maxy + (0.03*maxy))
     if(rev)
         ylimits <- rev(ylimits)
     max.abun <- sapply(x, function(x) round(max(x), 1))
@@ -62,12 +78,19 @@
                    y = list(axs = "r", limits = ylimits),
                    x = list(axs = "r", rot = 45, relation = "free"))
     par.strip.text <- list(cex = 0.75)
+    str.max <- 1
+    if(!isTRUE(strip)) {
+        str.max <- max(convertWidth(grobWidth(textGrob(levels(sx$ind),
+                                                       gp = gpar())),
+                                    "lines", valueOnly = TRUE))
+        str.max <- ceiling(str.max) + 3
+    }
     ## plotting
     xyplot(y ~ values | ind,
            data = sx,
            type = type,
            ylab = ylab, xlab = xlab,
-           strip.left = FALSE, strip = TRUE,
+           strip.left = FALSE, strip = strip,
            par.strip.text = par.strip.text,
            scales = scales,
            xlim = xlimits,
@@ -77,7 +100,8 @@
            },
            panel = "panel.Stratiplot",
            layout = c(n.vars, 1, pages),
-           par.settings = list(layout.widths = list(panel = max.abun)),
-           ##index.cond = list(ord),
+           par.settings = list(layout.widths = list(panel = max.abun),
+           layout.heights = list(top.padding = str.max)),
+           axis = if(isTRUE(strip)) {axis.default} else {axis.VarLabs},
            ...)
 }

Modified: pkg/inst/ChangeLog
===================================================================
--- pkg/inst/ChangeLog	2010-05-19 17:36:09 UTC (rev 171)
+++ pkg/inst/ChangeLog	2010-05-26 22:14:28 UTC (rev 172)
@@ -2,7 +2,12 @@
 
 Version 0.6-24
 
-	* panel.Stratiplot; fix warning messages (from Grid) due to
+	* Stratiplot: gains ability to draw variable labels above the
+	plot panels so that the plots conform to common standards. If
+	you prefer the 'strips' of Lattice plots, set 'strip = FALSE'
+	to get the old behaviour.
+
+	* panel.Stratiplot: fix warning messages (from Grid) due to
 	inappropriate colour specification. Reference lines in
 	Stratiplot now plot correctly again.
 

Modified: pkg/man/Stratiplot.Rd
===================================================================
--- pkg/man/Stratiplot.Rd	2010-05-19 17:36:09 UTC (rev 171)
+++ pkg/man/Stratiplot.Rd	2010-05-26 22:14:28 UTC (rev 172)
@@ -15,7 +15,7 @@
 
 \method{Stratiplot}{default}(x, y, type = "l", ylab = NULL, xlab = "",
            pages = 1, rev = TRUE, sort = c("none", "wa", "var"),
-           svar = NULL, rev.sort = FALSE, \dots)
+           svar = NULL, rev.sort = FALSE, strip = FALSE, \dots)
 
 \method{Stratiplot}{formula}(formula, data, subset, na.action, type = "l",
            ylab = NULL, xlab = "", pages = 1, \dots)
@@ -60,6 +60,9 @@
     \code{svar}.}
   \item{svar}{vector; optional variable to sort columns of \code{x} by.}
   \item{rev.sort}{logical; should the sorting order be reversed.}
+  \item{strip}{logical; Should panels have strips containing variable
+    labels drawn on them? Default is \code{FALSE}, which labels each
+    panel with a label resulting in a more familiar plot style.}
   \item{\dots}{additional arguments passed to
     \code{\link{panel.Stratiplot}} and the underlying
     \code{\link[lattice]{xyplot}} function.}



More information about the Analogue-commits mailing list