[Dplr-commits] r907 - in pkg/dplR: . R man

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Wed Nov 5 16:47:20 CET 2014


Author: mvkorpel
Date: 2014-11-05 16:47:20 +0100 (Wed, 05 Nov 2014)
New Revision: 907

Modified:
   pkg/dplR/ChangeLog
   pkg/dplR/DESCRIPTION
   pkg/dplR/R/spag.plot.R
   pkg/dplR/man/spag.plot.Rd
Log:
Added 'useRaster' and 'res' arguments to spag.plot(), as previously
used in wavelet.plot().


Modified: pkg/dplR/ChangeLog
===================================================================
--- pkg/dplR/ChangeLog	2014-11-05 15:39:58 UTC (rev 906)
+++ pkg/dplR/ChangeLog	2014-11-05 15:47:20 UTC (rev 907)
@@ -124,6 +124,14 @@
   plot with less than the full number of rows can fit in a smaller
   device and text on the sides won't be clipped.
 
+File: spag.plot.R
+-----------------
+
+- Added two options to spag.plot().
+  'useRaster': draw the tree-ring series as a raster image? (default
+     'FALSE')
+  'res': resolution of the tree-ring series when 'useRaster' is 'TRUE'
+
 File: timeseries-dplR.Rnw
 -------------------------
 

Modified: pkg/dplR/DESCRIPTION
===================================================================
--- pkg/dplR/DESCRIPTION	2014-11-05 15:39:58 UTC (rev 906)
+++ pkg/dplR/DESCRIPTION	2014-11-05 15:47:20 UTC (rev 907)
@@ -3,7 +3,7 @@
 Type: Package
 Title: Dendrochronology Program Library in R
 Version: 1.6.1
-Date: 2014-11-04
+Date: 2014-11-05
 Authors at R: c(person("Andy", "Bunn", role = c("aut", "cph",
         "cre", "trl"), email = "andy.bunn at wwu.edu"), person("Mikko",
         "Korpela", role = c("aut", "trl")), person("Franco", "Biondi",

Modified: pkg/dplR/R/spag.plot.R
===================================================================
--- pkg/dplR/R/spag.plot.R	2014-11-05 15:39:58 UTC (rev 906)
+++ pkg/dplR/R/spag.plot.R	2014-11-05 15:47:20 UTC (rev 907)
@@ -1,4 +1,5 @@
-spag.plot <- function(rwl, zfac=1, ...){
+spag.plot <- function(rwl, zfac=1, useRaster = FALSE, res = 150, ...){
+    stopifnot(is.logical(useRaster), length(useRaster) == 1)
     nseries <- ncol(rwl)
     if (nseries == 0) {
         stop("empty 'rwl' given, nothing to draw")
@@ -20,8 +21,23 @@
          axes=FALSE, ylab="", xlab=gettext("Year", domain="R-dplR"))
     abline(h=1:nseries, col="grey")
     grid(ny = NA)
-    for (i in 1:nseries) {
+    if (is.na(useRaster)) {
+        useRaster2 <- names(dev.cur()) %in% c("pdf", "postscript")
+    } else {
+        useRaster2 <- useRaster
+    }
+    cl <- quote(for (i in 1:nseries) {
         lines(yr, rwl2[, i], ...)
+    })
+    if (useRaster2) {
+        tryCatch(rasterPlot(cl, res = res),
+                 error = function(e) {
+                     message(as.character(e), appendLF = FALSE)
+                     message("reverting to useRaster=FALSE")
+                     eval(cl)
+                 })
+    } else {
+        eval(cl)
     }
     tmp.seq <- seq(from=1, to=nseries, by=2)
     axis(2, at=tmp.seq,

Modified: pkg/dplR/man/spag.plot.Rd
===================================================================
--- pkg/dplR/man/spag.plot.Rd	2014-11-05 15:39:58 UTC (rev 906)
+++ pkg/dplR/man/spag.plot.Rd	2014-11-05 15:47:20 UTC (rev 907)
@@ -5,13 +5,21 @@
   Makes a spaghetti plot of tree-ring data.
 }
 \usage{
-spag.plot(rwl, zfac = 1, \dots)
+spag.plot(rwl, zfac = 1, useRaster = FALSE, res = 150, \dots)
 }
 \arguments{
   \item{rwl}{ a \code{data.frame} with series as columns and years as
     rows such as that produced by \code{\link{read.rwl}}. }
   \item{zfac}{ a multiplier for \code{\var{rwl}} to enhance clarity when
     plotting. }
+  \item{useRaster}{A \code{logical} flag.  If \code{TRUE}, the tree-ring
+    series are drawn as a raster image.  Other parts of the plot are
+    not affected.  Other choices are \code{NA} (automatic) and
+    \code{FALSE} (use vector graphics, the default).  See
+    \code{\link{wavelet.plot}}.  }
+  \item{res}{A \code{numeric} vector of length 1.  The resolution
+    (pixels per inch) of the tree-ring series when a raster image is
+    used. }
   \item{\dots}{ arguments to be passed to \code{\link{lines}}. }
 }
 \details{



More information about the Dplr-commits mailing list