R: Plot a Continuous Wavelet Transform

wavelet.plot {dplR} | R Documentation

## 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", domain = "R-dplR"),
                 period.lab = gettext("Period", domain = "R-dplR"),
                 crn.lab = gettext("RWI", domain = "R-dplR"),
                 key.cols = rev(rainbow(length(wavelet.levels)-1)),
                 key.lab = parse(text=paste0("\"",
                                             gettext("Power",
                                                     domain="R-dplR"),
                                             "\"^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`.

### 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.

### Value

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

### Note

The function `morlet` is a port of Torrence’s IDL code, which can be accessed through the Internet Archive Wayback Machine.

### Author(s)

Andy Bunn. Patched and improved by Mikko Korpela.

### 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

    library(stats)
    library(utils)
    data(ca533)
    ca533.rwi <- detrend(rwl = ca533, method = "ModNegExp")
    ca533.crn <- chron(ca533.rwi, prefix = "CAM", prewhiten = FALSE)
    Years <- time(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)
    # Alternative palette with better separation of colors
    # via: rev(RColorBrewer::brewer.pal(10, "Spectral"))
    specCols <- c("#5E4FA2", "#3288BD", "#66C2A5", "#ABDDA4", "#E6F598",
                  "#FEE08B", "#FDAE61", "#F46D43", "#D53E4F", "#9E0142")
    wavelet.plot(out.wave, key.cols=specCols,useRaster = NA)

    # fewer colors
    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("#FFFFFF", "#ABDDA4", "#FDAE61", "#D7191C"), useRaster = NA)

[Package dplR version 1.7.1 Index]