Learn R Programming

wavethresh (version 4.6.1)

plot.wd: Plot wavelet transform coefficients.

Description

This function plots discrete wavelet transform coefficients arising from a wd object.

Usage

## S3 method for class 'wd':
plot(x,xlabvals, xlabchars, ylabchars, first.level = 0,
	main = "Wavelet Decomposition Coefficients", scaling = "global",
	rhlab = FALSE, sub, NotPlotVal = 0.005, xlab = "Translate",
	ylab = "Resolution Level", 
	aspect = "Identity", \dots)

Arguments

x
The wd class object you wish to plot
xlabvals
A vector containing the "true" x-axis numbers that went with the vector that was transformed to produce the wd object supplied as the first argument to this function. If this argument is missing then the functio
xlabchars
Tickmark labels for the x axis
ylabchars
Tickmark labels for the y axis
first.level
The first resolution level to begin plotting at. This argument can be quite useful when you want to supress some of the coarser levels in the diagram.
main
The main title of the plot.
scaling
How you want the coefficients to be scaled. The options are: global - one scale factor is chosen for the whole plot. The scale factor depends on the coefficient to be included on the plot that has the largest absolute value. The global<
rhlab
If TRUE then a set of labels is produced on the right hand axis. The axis labels in this case refer to the scale factors used to scale each level and correspond to value of the largest coefficient (in absolute value) in each scale (when
sub
A subtitle for the plot.
NotPlotVal
This argument ensures that if all (scaled) coefficients in a resolution level are below NotPlotVal in absolute value then the whole resolution level is not plotted. This can be useful when plotting a wd
xlab
A title for the x-axis
ylab
A title for the y-axis
aspect
This argument describes the name (as a character string) of a function to be applied to the coefficients before plotting. By default the argument is "Identity", i.e. the coefficients are plotted as is. This argument is most useful wh
...
fine tuning

Value

  • If rhlab==T then the scaling factors applied to each scale level are returned. Otherwise NULL is returned.

RELEASE

Version 3.5.3 Copyright Guy Nason 1994

Details

Produces a plot similar to the ones in Donoho and Johnstone, 1994.

A wavelet decomposition of a signal consists of discrete wavelet coefficients at different scales (resolution levels) and locations. This function plots the coefficients as a pyramid (derived from Mallat's pyramid algorithm). See the examples below.

The resolution levels are stacked one above the other: coarse scale coefficients are always towards the top of the plot, fine scale coefficients are always located toward the bottom of the plot. The location of coefficients increases from left to right across the plot in synchrony with the input signal to the wd object. In other words the position of a coefficient along a line is indicative of the associated wavelet basis function's translate number. The actual coefficients are plotted using S-Plus's segments() function. This plots each coefficient as a vertical line with positive coefficients being plotted above an imaginary centre line and negative coefficients being plotted below.

The resolution levels are labelled on the left-hand side axis, and if rhlab==T the maximum values of the absolute values of the coefficients, for the particular level, are plotted on the right-hand axis.

The coefficients in the plot may be scaled in 4 ways. If you are interested in comparing coefficients in different levels then the default scaling option scaling=="global" is what you need. This works by finding the coefficient with the largest absolute value amongst all coeffients to be plotted and then scales all the other coefficients by the largest so that all coefficients lie in the range -1/2 to 1/2. The scaled coefficients are then plotted. If you are not interested in comparing relative resolution levels and want to see all that goes on within a particular scale then you should use the scaling option scaling=="by.level" which picks out the largest coefficient (in absolute value) from each level and scales each level separately. The "compensated" and super options are like the "global" option except that finer levels are scaled up (as discussed in the arguments list above): this can be useful when plotting non-decimated wavelet transform coefficients as it emphasizes the higher frequencies.

See Also

wd

Examples

Run this code
#
# Generate some test data
#
test.data <- example.1()$y
ts.plot(test.data)
#
# Decompose test.data and plot the wavelet coefficients
#
wds <- wd(test.data)
plot(wds)
#
# Now do the time-ordered non-decimated wavelet transform of the same thing
#
wdS <- wd(test.data, type="station")
plot(wdS)
#
# Next examples
# ------------
# The chirp signal is also another good examples to use.
#
# Generate some test data
#
test.chirp <- simchirp()$y
ts.plot(test.chirp, main="Simulated chirp signal")
#
# Now let's do the time-ordered non-decimated wavelet transform.
# For a change let's use Daubechies least-asymmetric phase wavelet with 8
# vanishing moments (a totally arbitrary choice, please don't read
# anything into it).
#
chirpwdS <- wd(test.chirp, filter.number=8, family="DaubLeAsymm", type="station")
plot(chirpwdS, main="TOND WT of Chirp signal")

Run the code above in your browser using DataLab