Learn R Programming

dplR (version 1.6.4)

wavelet.plot: Plot a Continuous Wavelet Transform

Description

This function creates a filled.contour plot of a continuous wavelet transform as output from morlet.

Usage

wavelet.plot(wave.list, wavelet.levels = quantile(wave.list$Power, probs = (0:10)/10), add.coi = TRUE, add.sig = TRUE, x.lab = gettext("Time"), period.lab = gettext("Period"), crn.lab = gettext("RWI"), key.cols = rev(rainbow(length(wavelet.levels)-1)), key.lab = parse(text=paste0("\"", gettext("Power"), "\"^2")), add.spline = FALSE, f = 0.5, nyrs = NULL, crn.col = "black", crn.lwd = 1,coi.col='black', crn.ylim = range(wave.list$y) * c(0.95, 1.05), side.by.side = FALSE, useRaster = FALSE, res = 150, reverse.y = FALSE, ...)

Arguments

wave.list
A list. Output from morlet.
wavelet.levels
A numeric vector. Values for levels of the filled contours for the wavelet plot.
add.coi
A logical flag. Add cone of influence?
add.sig
A logical flag. Add contour lines for significance?
x.lab
X-axis label.
period.lab
Y-axis label for the wavelet plot.
crn.lab
Y-axis label for the time-series plot.
key.cols
A vector of colors for the wavelets and the key.
key.lab
Label for key.
add.spline
A logical flag. Add a spline to the time-series plot using ffcsaps?.
nyrs
A number giving the rigidity of the smoothing spline, defaults to 0.33 of series length if nyrs is NULL.
f
A number between 0 and 1 giving the frequency response or wavelength cutoff for the smoothing spline. Defaults to 0.5.
crn.col
Line color for the time-series plot.
crn.lwd
Line width for the time-series plot.
coi.col
Color for the COI if add.coi is TRUE.
crn.ylim
Axis limits for the time-series plot.
side.by.side
A logical flag. Plots will be in one row if TRUE.
useRaster
A logical flag. If TRUE, the filled contours are drawn as a raster image. Other parts of the plot are not affected. useRaster=TRUE can be especially useful when a pdf device is used: the size and complexity of the PDF file will probably be greatly reduced. Setting this to TRUE has negative effects when used with a bitmap device such as png. If NA, plotting of a raster image will be attempted if and only if the name of the graphics device is "pdf" or "postscript". The default is FALSE: draw directly to the graphics device without using an intermediate raster image.
res
A numeric vector of length 1. The resolution (pixels per inch) of the filled contours when a raster image is used. See useRaster.
reverse.y
A logical flag. If TRUE, the Y-axis will be reversed, i.e. period increasing towards the bottom. The default is FALSE.
...
Arguments passed to rasterPlot. Only relevant when the filled contours are drawn as a raster image. See useRaster.

Value

None. This function is invoked for its side effect, which is to produce a plot.

Details

This produces a plot of a continuous wavelet transform and plots the original time series. Contours are added for significance and a cone of influence polygon can be added as well. Anything within the cone of influence should not be interpreted.

The time series can be plotted with a smoothing spline as well.

References

Torrence, C. and Compo, G. P. (1998) A practical guide to wavelet analysis. Bulletin of the American Meteorological Society, 79(1), 61–78.

See Also

morlet, ffcsaps

Examples

Run this code
library(utils)
data(ca533)
ca533.rwi <- detrend(rwl = ca533, method = "ModNegExp")
ca533.crn <- chron(ca533.rwi, prefix = "CAM", prewhiten = FALSE)
Years <- as.numeric(rownames(ca533.crn))
CAMstd <- ca533.crn[, 1]
out.wave <- morlet(y1 = CAMstd, x1 = Years, p2 = 9, dj = 0.1,
                   siglvl = 0.99)
wavelet.plot(out.wave, useRaster = NA)
## Not run: 
# ## Alternative palette with better separation of colors
# if (require(RColorBrewer)) {
#   ## RColorBrewer (1.1.2) uses but does not import rgb()
#   library(grDevices)
#   wavelet.plot(out.wave, key.cols=rev(brewer.pal(10, "Spectral")),
#                useRaster = NA)
# }
# ## End(Not run)
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"),
             useRaster = NA)

Run the code above in your browser using DataLab