[Analogue-commits] r177 - in pkg: R inst man

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Wed Jun 23 22:53:54 CEST 2010


Author: gsimpson
Date: 2010-06-23 22:53:54 +0200 (Wed, 23 Jun 2010)
New Revision: 177

Modified:
   pkg/R/Stratiplot.R
   pkg/inst/ChangeLog
   pkg/man/Stratiplot.Rd
Log:
fix handling ylim in Stratiplot so it works more intuitively

Modified: pkg/R/Stratiplot.R
===================================================================
--- pkg/R/Stratiplot.R	2010-05-29 15:16:23 UTC (rev 176)
+++ pkg/R/Stratiplot.R	2010-06-23 20:53:54 UTC (rev 177)
@@ -8,6 +8,7 @@
                                  xlab = "",
                                  pages = 1,
                                  rev = TRUE,
+                                 ylim,
                                  sort = c("none", "wa", "var"),
                                  svar = NULL,
                                  rev.sort = FALSE,
@@ -69,13 +70,19 @@
     }
     ## plot parameters
     maxy <- max(y)
-    ylimits <- c(0 - (0.03*maxy), maxy + (0.03*maxy))
+    miny <- min(y)
+    if(missing(ylim)) {
+        ylim <- c(miny - (0.03*maxy), maxy + (0.03*maxy))
+    } else {
+        ylim <- c(min(ylim) - (0.03*max(ylim)),
+                  max(ylim) + (0.03*max(ylim)))
+    }
     if(rev)
-        ylimits <- rev(ylimits)
+        ylim <- rev(ylim)
     max.abun <- sapply(x, function(x) round(max(x), 1))
     xlimits <- lapply(max.abun * 1.05, function(x) c(0, x))
     scales <- list(cex = 0.75, tck = 0.75,
-                   y = list(axs = "r", limits = ylimits),
+                   y = list(axs = "r", limits = ylim),
                    x = list(axs = "r", rot = 45, relation = "free"))
     par.strip.text <- list(cex = 0.75)
     str.max <- 1
@@ -83,7 +90,7 @@
         str.max <- max(convertWidth(grobWidth(textGrob(levels(sx$ind),
                                                        gp = gpar())),
                                     "lines", valueOnly = TRUE))
-        str.max <- ceiling(str.max) + 3
+        str.max <- ceiling(str.max) + 4
     }
     ## plotting
     xyplot(y ~ values | ind,
@@ -94,10 +101,11 @@
            par.strip.text = par.strip.text,
            scales = scales,
            xlim = xlimits,
-           prepanel = function(x, y, ...) {
-               list(xlim = c(0, max(x)),
-                    ylim = rev(c(0, max(y))))
-           },
+           ylim = ylim,
+           #prepanel = function(x, y, ...) {
+           #    list(xlim = c(0, max(x)),
+           #         ylim = rev(c(0, max(y))))
+           #},
            panel = "panel.Stratiplot",
            layout = c(n.vars, 1, pages),
            par.settings = list(layout.widths = list(panel = max.abun),

Modified: pkg/inst/ChangeLog
===================================================================
--- pkg/inst/ChangeLog	2010-05-29 15:16:23 UTC (rev 176)
+++ pkg/inst/ChangeLog	2010-06-23 20:53:54 UTC (rev 177)
@@ -6,9 +6,14 @@
 
 	* 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'
+	you prefer the 'strips' of Lattice plots, set 'strip = TRUE'
 	to get the old behaviour.
 
+	Stratiplot was fixinging the min(ylim) value at 0 and contained
+	redundant calls to set the y-axis limits. The behaviour has been
+	rationalised and a new 'ylim' argument added. The default
+	behaviour uses the range of the y-data for 'ylim'.
+
 	* 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-29 15:16:23 UTC (rev 176)
+++ pkg/man/Stratiplot.Rd	2010-06-23 20:53:54 UTC (rev 177)
@@ -14,7 +14,7 @@
 Stratiplot(x, \dots)
 
 \method{Stratiplot}{default}(x, y, type = "l", ylab = NULL, xlab = "",
-           pages = 1, rev = TRUE, sort = c("none", "wa", "var"),
+           pages = 1, rev = TRUE, ylim, sort = c("none", "wa", "var"),
            svar = NULL, rev.sort = FALSE, strip = FALSE, \dots)
 
 \method{Stratiplot}{formula}(formula, data, subset, na.action, type = "l",
@@ -51,6 +51,12 @@
   \item{pages}{numeric; the number of pages to draw the plot over. May
     be useful for data sets with many species.}
   \item{rev}{logical; should the y-axis limits be reversed}
+  \item{ylim}{user supplied limits for the y-axis (time/depth). If not
+    supplied, suitable limits will be determined from the data. As such,
+    in general use \code{ylim} need not be supplied. If you choose to
+    supply your own \code{ylim} values, note the default for argument
+    \code{rev}; the default will reverse the values you supply to
+    \code{ylim}.}
   \item{sort}{character; how should the variables (columns) of \code{x}
     be sorted on the plot. \code{"wa"} sorts by weighted averages
     of variable \code{svar} if not \code{NULL} or of \code{y}



More information about the Analogue-commits mailing list