[Dplr-commits] r885 - in pkg/dplR: R man vignettes

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Mon May 19 12:39:06 CEST 2014


Author: mvkorpel
Date: 2014-05-19 12:39:06 +0200 (Mon, 19 May 2014)
New Revision: 885

Modified:
   pkg/dplR/R/wavelet.plot.R
   pkg/dplR/man/wavelet.plot.Rd
   pkg/dplR/vignettes/timeseries-dplR.Rnw
Log:
There is one new choice for the value of the 'useRaster' argument of
wavelet.plot(): NA.  When used, this effectively sets useRaster to
TRUE if and only if the name of the graphics device is either "pdf" or
"postscript".  The examples and the timeseries vignette now also use
useRaster = NA.  The default is still FALSE.


Modified: pkg/dplR/R/wavelet.plot.R
===================================================================
--- pkg/dplR/R/wavelet.plot.R	2014-05-19 09:45:29 UTC (rev 884)
+++ pkg/dplR/R/wavelet.plot.R	2014-05-19 10:39:06 UTC (rev 885)
@@ -22,14 +22,14 @@
 
     stopifnot(is.numeric(x), is.numeric(y), is.numeric(period),
               is.numeric(Signif), is.numeric(coi), is.numeric(Power),
-              is.numeric(siglvl))
+              is.numeric(siglvl), is.logical(useRaster),
+              length(useRaster) == 1)
     n.x <- length(x)
     n.period <- length(period)
     dim.Power <- dim(Power)
     stopifnot(length(dim.Power) == 2, n.x == length(y), dim.Power[1] == n.x,
               dim.Power[2] == n.period, length(Signif) == n.period,
               length(coi) == n.x, length(siglvl) == 1, n.x >= 2, n.period >= 2)
-
     if (any(diff(x) <= 0) || any(diff(period) <= 0)) {
         stop("'wave.list$x' and 'wave.list$period' must be strictly ascending")
     }
@@ -92,9 +92,14 @@
         plot.new()
 
         plot.window(xlim, ylim, "", xaxs=xaxs, yaxs=yaxs, asp=asp, las=las)
-        # note replacement of .Internal(filledcontour(as.double(x),...)
-        # with .filled.contour() as of R-2.15.0
-        if (isTRUE(useRaster)) {
+        if (is.na(useRaster)) {
+            useRaster2 <- names(dev.cur()) %in% c("pdf", "postscript")
+        } else {
+            useRaster2 <- useRaster
+        }
+        ## note replacement of .Internal(filledcontour(as.double(x),...)
+        ## with .filled.contour() as of R-2.15.0
+        if (useRaster2) {
             cl <- quote(.filled.contour(as.double(x),
                                         as.double(period2),
                                         z,
@@ -179,9 +184,14 @@
         plot.new()
 
         plot.window(xlim, ylim, "", xaxs=xaxs, yaxs=yaxs, asp=asp, las=las)
-        # note replacement of .Internal(filledcontour(as.double(x),...)
-        # with .filled.contour() as of R-2.15.0
-        if (isTRUE(useRaster)) {
+        if (is.na(useRaster)) {
+            useRaster2 <- names(dev.cur()) %in% c("pdf", "postscript")
+        } else {
+            useRaster2 <- useRaster
+        }
+        ## note replacement of .Internal(filledcontour(as.double(x),...)
+        ## with .filled.contour() as of R-2.15.0
+        if (useRaster2) {
             cl <- quote(.filled.contour(as.double(x),
                                         as.double(period2),
                                         z,

Modified: pkg/dplR/man/wavelet.plot.Rd
===================================================================
--- pkg/dplR/man/wavelet.plot.Rd	2014-05-19 09:45:29 UTC (rev 884)
+++ pkg/dplR/man/wavelet.plot.Rd	2014-05-19 10:39:06 UTC (rev 885)
@@ -45,11 +45,15 @@
     not affected.  \code{useRaster=TRUE} can be especially useful when a
     \code{pdf} device is used: the size and complexity of the
     \acronym{PDF} file will probably be greatly reduced.  Setting this
-    to \code{TRUE} only has negative effects when used with a bitmap
-    device such as \code{png}.  The default is \code{FALSE}.  }
+    to \code{TRUE} has negative effects when used with a bitmap
+    device such as \code{png}.  If \code{NA}, plotting of a raster image
+    will be attempted if and only if the name of the graphics device is
+    \code{"pdf"} or \code{"postscript"}.  The default is \code{FALSE}:
+    draw directly to the graphics device without using an intermediate
+    raster image.  }
   \item{res}{A \code{numeric} vector of length 1.  The resolution
-    (pixels per inch) of the filled contours when \code{useRaster} is
-    \code{TRUE}.}
+    (pixels per inch) of the filled contours when a raster image is
+    used.  See \code{useRaster}.}
   \item{reverse.y}{A \code{logical} flag.  If \code{TRUE}, the Y-axis
     will be reversed, i.e. period increasing towards the bottom.  The
     default is \code{FALSE}. }
@@ -84,15 +88,17 @@
 CAMstd <- ca533.crn[, 1]
 out.wave <- morlet(y1 = CAMstd, x1 = Years, p2 = 9, dj = 0.1,
                    siglvl = 0.99)
-wavelet.plot(out.wave)
+wavelet.plot(out.wave, useRaster = NA)
 \dontrun{
 ## Alternative palette with better separation of colors
 if (require(RColorBrewer)) {
-  wavelet.plot(out.wave, key.cols=rev(brewer.pal(10, "Spectral")))
+  wavelet.plot(out.wave, key.cols=rev(brewer.pal(10, "Spectral")),
+               useRaster = NA)
 }
 }
 levs <- quantile(out.wave$Power, probs = c(0, 0.5, 0.75, 0.9, 0.99))
 wavelet.plot(out.wave, wavelet.levels = levs, add.sig = FALSE,
-             key.cols = c("white", "green", "blue", "red"))
+             key.cols = c("white", "green", "blue", "red"),
+             useRaster = NA)
 }
 \keyword{ hplot }

Modified: pkg/dplR/vignettes/timeseries-dplR.Rnw
===================================================================
--- pkg/dplR/vignettes/timeseries-dplR.Rnw	2014-05-19 09:45:29 UTC (rev 884)
+++ pkg/dplR/vignettes/timeseries-dplR.Rnw	2014-05-19 10:39:06 UTC (rev 885)
@@ -239,7 +239,7 @@
 yrs <- as.numeric(rownames(co021.crn))
 out.wave <- morlet(y1 = dat, x1 = yrs, p2 = 8, dj = 0.1,
                    siglvl = 0.99)
-wavelet.plot(out.wave, useRaster=TRUE)
+wavelet.plot(out.wave, useRaster=NA)
 @
 \begin{figure}[h]
   \centering



More information about the Dplr-commits mailing list