Description Usage Arguments Value Author(s) References See Also Examples
View source: R/wc.phasediff.image.R
This function plots the phase difference image of two time series, which is
provided by an object of class "analyze.coherency"
.
The vertical axis shows the Fourier periods. The horizontal axis shows time step counts, but can
be easily transformed into a calendar axis if dates are provided in either row names or a variable
named "date"
in the data frame at hand. Both axes can be relabeled.
In particular, an option is given to individualize the period and/or time axis
by specifying tick marks and labels.
The color levels are defined according to equidistant breakpoints
(covering the interval from -pi
to +pi
), with the number of levels
as a further parameter. In addition, there is an option to adopt
an individual color palette.
If the default palette is retained, colors indicate the following. Green:
phase differences close to zero, which means that the two time
series are in phase at the respective period. Yellowgreen: in
phase, series 1 leading. Turquoise: in phase, series 2 leading.
Red: phase differences are close to +pi
, out of phase, series
2 leading. Blue: phase differences are close to -pi
, out of
phase, series 1 leading.
Further plot design options concern: plot of the cone of influence, plot of contour lines to border areas of significance with respect to cross-wavelet power or wavelet coherence at a given significance level.
Finally, there is an option to insert and format a color legend (a right-hand vertical color bar) and to set the plot title. For further processing of the plot, graphical parameters of plot regions are provided as output.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | wc.phasediff.image(WC, use.sAngle = FALSE,
plot.coi = TRUE,
plot.contour = TRUE, which.contour = "wp",
siglvl = 0.1, col.contour = "white",
n.levels = 100,
color.palette = "rainbow(n.levels, start = 0, end = .7)",
useRaster = TRUE, max.contour.segments = 250000,
plot.legend = TRUE,
legend.params = list(width = 1.2, shrink = 0.9, mar = 5.1,
n.ticks = 6,
pi.style = TRUE,
label.digits = 1, label.format = "f",
lab = NULL, lab.line = 3),
label.time.axis = TRUE,
show.date = FALSE, date.format = NULL, date.tz = NULL,
timelab = NULL, timetck = 0.02, timetcl = 0.5,
spec.time.axis = list(at = NULL, labels = TRUE,
las = 1, hadj = NA, padj = NA),
label.period.axis = TRUE,
periodlab = NULL, periodtck = 0.02, periodtcl = 0.5,
spec.period.axis = list(at = NULL, labels = TRUE,
las = 1, hadj = NA, padj = NA),
main = NULL,
lwd = 2, lwd.axis = 1,
graphics.reset = TRUE,
verbose = FALSE)
|
WC |
an object of class |
use.sAngle |
Use smoothed version of phase difference? Logical. Default: |
plot.coi |
Plot cone of influence? Logical. Default: |
plot.contour |
Plot contour lines to border the area of cross-wavelet power (or wavelet coherence,
depending on Default: | ||||||||
which.contour |
Contour lines of which spectrum should be plotted?
Default: | ||||||||
siglvl |
level of cross-wavelet power (or wavelet coherence, depending on Default: | ||||||||
col.contour |
color of contour lines. Default: |
n.levels |
Number of color levels. Default: |
color.palette |
Definition of color levels. (The color palette will be assigned to levels in reverse order!) Default: |
useRaster |
Use a bitmap raster instead of polygons to plot the image? Logical. Default: |
max.contour.segments |
limit on the number of segments in a single contour line, positive integer. Default: |
plot.legend |
Plot color legend (a vertical bar of colors and breakpoints)? Logical. Default: |
legend.params |
a list of parameters for the plot of the color legend; parameter values can be set selectively
(style in parts adopted from
|
label.time.axis |
Label the time axis? Logical. Default: |
show.date |
Show calendar dates? (Effective only if dates are available as row names or by variable
Default: |
date.format |
the format of calendar date given as a character string, e.g. Default: |
date.tz |
a character string specifying the time zone of calendar date; see Default: |
timelab |
Time axis label. Default: |
timetck |
length of tick marks on the time axis as a fraction of the smaller of the width or height of the plotting region; see Default here: |
timetcl |
length of tick marks on the time axis as a fraction of the height of a line of text; see Default here: |
spec.time.axis |
a list of tick mark and label specifications for individualized time axis labeling
(only effective if
Mismatches will result in a reset to default plotting. |
label.period.axis |
Label the (Fourier) period axis? Logical. Default: |
periodlab |
(Fourier) period axis label. Default: |
periodtck |
length of tick marks on the period axis as a fraction of the smaller of the width or height
of the plotting region; see Default here: |
periodtcl |
length of tick marks on the period axis as a fraction of the height of a line of text; see Default here: |
spec.period.axis |
a list of tick mark and label specifications for individualized period axis labeling
(only effective if
Mismatches will result in a reset to default plotting. |
main |
an overall title for the plot. Default: |
lwd |
line width of contour lines and ridge. Default: |
lwd.axis |
line width of axes (image and legend bar). Default: |
graphics.reset |
Reset graphical parameters? Logical. Default: |
verbose |
Print verbose output on the screen? Logical. Default: |
A list of class graphical parameters
with the following elements:
op |
original graphical parameters |
image.plt |
image plot region |
legend.plt |
legend plot region |
Angi Roesch and Harald Schmidbauer
Aguiar-Conraria L., and Soares M.J., 2011. Business cycle synchronization and the Euro: A wavelet analysis. Journal of Macroeconomics 33 (3), 477–489.
Aguiar-Conraria L., and Soares M.J., 2011. The Continuous Wavelet Transform: A Primer. NIPE Working Paper Series 16/2011.
Cazelles B., Chavez M., Berteaux, D., Menard F., Vik J.O., Jenouvrier S., and Stenseth N.C., 2008. Wavelet analysis of ecological time series. Oecologia 156, 287–304.
Liu P.C., 1994. Wavelet spectrum analysis and ocean wind waves. In: Foufoula-Georgiou E., and Kumar P., (eds.), Wavelets in Geophysics, Academic Press, San Diego, 151–166.
Torrence C., and Compo G.P., 1998. A practical guide to wavelet analysis. Bulletin of the American Meteorological Society 79 (1), 61–78.
Veleda D., Montagne R., and Araujo M., 2012. Cross-Wavelet Bias Corrected by Normalizing Scales. Journal of Atmospheric and Oceanic Technology 29, 1401–1408.
analyze.coherency
, wc.image
, wc.avg
, wc.sel.phases
, wt.image
, wt.avg
, wt.sel.phases
, wt.phase.image
, reconstruct
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 | ## Not run:
## The following example is modified from Veleda et al., 2012:
series.length <- 3*128*24
x1 <- periodic.series(start.period = 1*24, length = series.length)
x2 <- periodic.series(start.period = 2*24, length = series.length)
x3a <- periodic.series(start.period = 4*24, length = series.length)
x3b <- periodic.series(start.period = 4*24, length = series.length,
phase = 24)
x4 <- periodic.series(start.period = 8*24, length = series.length)
x5 <- periodic.series(start.period = 16*24, length = series.length)
x6 <- periodic.series(start.period = 32*24, length = series.length)
x7 <- periodic.series(start.period = 64*24, length = series.length)
x8 <- periodic.series(start.period = 128*24, length = series.length)
x <- x1 + x2 + x3a + x4 + 3*x5 + x6 + x7 + x8 + rnorm(series.length)
y <- x1 + x2 + x3b + x4 - 3*x5 + x6 + 3*x7 + x8 + rnorm(series.length)
matplot(data.frame(x, y), type = "l", lty = 1, xaxs = "i", col = 1:2,
xlab = "index", ylab = "",
main = "hourly series with periods of 1, 2, 4, 8, 16, 32, 64, 128 days",
sub = "(different phases at periods 4 and 16)")
legend("topright", legend = c("x","y"), col = 1:2, lty = 1)
## The following dates refer to the local time zone
## (possibly allowing for daylight saving time):
my.date <- seq(as.POSIXct("2014-10-14 00:00:00", format = "%F %T"),
by = "hour",
length.out = series.length)
my.data <- data.frame(date = my.date, x = x, y = y)
## Computation of cross-wavelet power and wavelet coherence, x over y:
## a natural choice of 'dt' in the case of hourly data is 'dt = 1/24',
## resulting in one time unit equaling one day.
## This is also the time unit in which periods are measured.
my.wc <- analyze.coherency(my.data, c("x","y"),
loess.span = 0,
dt = 1/24, dj = 1/20,
window.size.t = 1, window.size.s = 1/2,
lowerPeriod = 1/4,
make.pval = TRUE, n.sim = 10)
## Plot of cross-wavelet power spectrum,
## with color breakpoints according to quantiles:
wc.image(my.wc,
main = "cross-wavelet power spectrum, x over y",
legend.params = list(lab = "cross-wavelet power levels (quantiles)"),
periodlab = "period (days)")
## Default plot of phase differences
## (with contour lines referring to cross-wavelet power)
wc.phasediff.image(my.wc, which.contour = "wp",
main = "image of phase differences, x over y",
periodlab = "period (days)")
## With time elapsed in days
## (starting from 0 and proceeding in steps of 50 days)
## instead of the (default) time index:
index.ticks <- seq(1, series.length, by = 50*24)
index.labels <- (index.ticks-1)/24
wc.phasediff.image(my.wc, which.contour = "wp",
main = "image of phase differences, x over y",
periodlab = "period (days)",
timelab = "time elapsed (days)",
spec.time.axis = list(at = index.ticks, labels = index.labels))
## The same plot, but with (automatically produced) calendar axis:
wc.phasediff.image(my.wc, which.contour = "wp",
main = "image of phase differences, x over y",
periodlab = "period (days)",
show.date = TRUE, date.format = "%F %T")
## For further axis plotting options:
## Please see the examples in our guide booklet,
## URL http://www.hs-stat.com/projects/WaveletComp/WaveletComp_guided_tour.pdf.
## Plot of phase difference with numerals as labels of the color legend bar:
wc.phasediff.image(my.wc,
legend.params=list(pi.style = FALSE, label.digits = 2))
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.