Plot cross wavelet scalogram using the outcome of the analyse_Xwavelet function.
Usage
plot_Xwavelet(
Xwavelet = NULL,
lowerPeriod = NULL,
upperPeriod = NULL,
n.levels = 100,
palette_name = "viridis",
color_brewer = "viridis",
useRaster = TRUE,
periodlab = "Period (metres)",
x_lab = "depth (metres)",
keep_editable = FALSE,
dev_new = wr_dev_new_default(),
plot_dir = TRUE,
plot_arrows = TRUE,
pwr_quant = 0.85,
n_arrows = 75,
T_unit = NULL,
P_unit = NULL,
arrow_length = 0.075,
arrow_lwd = 1.9,
arrow_angle = 25,
add_lines = NULL,
add_points = NULL,
add_abline_h = NULL,
add_abline_v = NULL,
add_data = TRUE,
add_avg = FALSE,
plot_horizontal = TRUE,
colour_brewer = NULL
)Arguments
- Xwavelet
Cross wavelet result to plot: the list returned by
analyse_Xwavelet(computed from the two recordsdata_1anddata_2). Required (Default=NULLgives an error).- lowerPeriod
Shortest period shown on the period axis, in the depth/time unit of the input records (numeric, > 0).
NULLuses the shortest period ofXwavelet.Default=NULL.- upperPeriod
Longest period shown on the period axis, in the depth/time unit of the input records (numeric, >
lowerPeriod).NULLuses the longest period ofXwavelet.Default=NULL.- n.levels
Number of colour levels of the power scale (integer, >= 2); the level breaks are the quantiles of the cross power, so each colour covers the same share of the scalogram.
Default=100.- palette_name
Name of the colour palette of the power (colour) scale, a character string. Which names are valid depends on
color_brewer:color_brewer = "grDevices":"rainbow","heat.colors","terrain.colors","topo.colors","cm.colors", or any of the 115hcl.colorspalettes (list them withgrDevices::hcl.pals()), for example"viridis","Plasma","Inferno","YlOrRd","Spectral","Blue-Red","Zissou 1".color_brewer = "viridis":"viridis","magma","inferno","plasma","cividis","rocket","mako","turbo".color_brewer = "RColorBrewer":"BrBG","PiYG","PRGn","PuOr","RdBu","RdGy","RdYlBu","RdYlGn","Spectral","Accent","Dark2","Paired","Pastel1","Pastel2","Set1","Set2","Set3","Blues","BuGn","BuPu","GnBu","Greens","Greys","Oranges","OrRd","PuBu","PuBuGn","PuRd","Purples","RdPu","Reds","YlGn","YlGnBu","YlOrBr","YlOrRd"(also listed bywr_brewer_palettes()).color_brewer = "colorRamps":"blue2green","blue2green2red","blue2red","blue2yellow","cyan2yellow","green2red","magenta2green","matlab.like","matlab.like2","ygobb".color_brewer = "scico"(all except"batlowK"need the scico package):"acton","bam","bamako","bamO","batlow","batlowK","batlowW","berlin","bilbao","broc","brocO","buda","bukavu","cork","corkO","davos","devon","fes","glasgow","grayC","hawaii","imola","lajolla","lapaz","lipari","lisbon","managua","navia","nuuk","oleron","oslo","roma","romaO","tofino","tokyo","turku","vanimo","vik","vikO".
Low power is drawn with the first colour of the palette and high power with the last.
Default="viridis".- color_brewer
Palette family from which
palette_nameis taken, a character string:"grDevices","viridis","RColorBrewer","colorRamps"or"scico"(the last one, except for"batlowK", needs the scico package). Seepalette_namefor the palette names of each family.Default="viridis".- useRaster
Draw the scalogram as a raster image (
TRUE) or as vector polygons (FALSE) (logical). WARNING: plotting as a vector image is computationally intensive and gives large files.Default=TRUE.- periodlab
Label of the period axis (character).
Default="Period (metres)".- x_lab
Label of the depth/time axis (character).
Default="depth (metres)".- keep_editable
Keep the plot layout and graphical parameters (
par) after plotting, so that extra elements can be added to the scalogram panel withlines,pointsetc. (logical). WithFALSEthe previousparsettings are restored on exit.Default=FALSE.- dev_new
Open a new plotting window for the plot (logical, TRUE or FALSE). The wavelet plots contain a raster image that needs more room than the small RStudio plot pane, which gives "figure margins too large" errors or clipped text, so a separate window is opened by default in the RStudio GUI. In every other front end (plain R, ESS, Positron, knitr, Rscript) the plot is drawn on the current device and no window is opened. Set TRUE or FALSE to force either behaviour, or set
options(waverider.dev_new = TRUE/FALSE).Default=wr_dev_new_default(): TRUE in the RStudio GUI, FALSE elsewhere.- plot_dir
Direction of the depth/time axis (logical).
TRUEplots increasing depth/time values from left to right (or bottom to top whenplot_horizontal=FALSE);FALSEreverses the axis.Default=TRUE.- plot_arrows
Draw the phase arrows of the cross wavelet transform on the scalogram (logical). An arrow is drawn at each local maximum of cross power along the period axis whose power exceeds the
pwr_quantquantile; its direction gives the phase difference between the two records (radians, measured anticlockwise from the depth/time axis).Default=TRUE.- pwr_quant
Quantile of the cross power (numeric, between 0 and 1) above which phase arrows are drawn; higher values keep only the arrows on the strongest power ridges.
Default=0.85.- n_arrows
Approximate number of arrow positions along the depth/time axis (integer, >= 1); every
round(n/n_arrows)-th depth/time step of thensteps gets arrows.Default=75.- T_unit
Length of the arrows along the depth/time axis, in depth/time units (numeric, > 0).
NULL(orP_unit=NULL) gives arrows of a fixed visual length of 0.3 inch whatever the record length.Default=NULL.- P_unit
Length of the arrows along the period axis, in log2(period) units (numeric, > 0).
NULL(orT_unit=NULL) uses the automatic arrow length (seeT_unit).Default=NULL.- arrow_length
Length of the arrow head edges in inches (numeric, > 0;
lengthargument ofarrows).Default=0.075.- arrow_lwd
Line width of the arrows (numeric, > 0).
Default=1.9.- arrow_angle
Angle between the arrow shaft and the edges of the arrow head, in degrees (numeric, 0-90).
Default=25.- add_lines
Lines to draw on the scalogram: a matrix or data frame with depth/time in column 1 and, in each further column, period values (same unit as the period axis) of one line;
NULLdraws none.Default=NULL.- add_points
Points to draw on the scalogram: a matrix or data frame with depth/time in column 1 and, in each further column, period values of one series of points;
NULLdraws none.Default=NULL.- add_abline_h
Numeric vector of positions of horizontal lines, e.g.
c(2, 3, 5, 6): periods whenplot_horizontal=TRUE, depth/time values whenplot_horizontal=FALSE;NULLdraws none.Default=NULL.- add_abline_v
Numeric vector of positions of vertical lines, e.g.
c(2, 3, 5, 6): depth/time values whenplot_horizontal=TRUE(also drawn on the data panel), periods whenplot_horizontal=FALSE;NULLdraws none.Default=NULL.- add_data
Plot the two input records (record 1 in black, record 2 in red) in a panel beside the scalogram (logical).
Default=TRUE.- add_avg
Plot the time-averaged cross power spectrum in a panel beside the scalogram (logical).
Default=FALSE.- plot_horizontal
Orientation of the plot (logical):
TRUEputs depth/time on the x axis and period on the y axis;FALSEputs depth/time on the y axis and period on the x axis.Default=TRUE.- colour_brewer
British spelling of
color_brewer, with the same options; if given (notNULL) it overridescolor_brewer.Default=NULL.
References
Roesch, A., & Schmidbauer, H. (2018). WaveletComp: Computational Wavelet Analysis. R package version 1.1. https://CRAN.R-project.org/package=WaveletComp
Moca, V. V., Bârzan, H., Nagy-Dăbâcan, A., & Mureșan, R. C. (2021). Time-frequency super-resolution with superlets. Nature Communications, 12(1), 337. doi:10.1038/s41467-020-20539-9
Author
plotting code based on the "wt.image" and "analyze.coherency" functions of the 'WaveletComp' R package
Examples
# \donttest{
#Example 1. A cross superlet plot of two etp solutions with noise overprint
etp_1 <- astrochron::etp(
tmin = 0,
tmax = 1500,
dt = 1,
eWt = 1.5,
oWt = 0.75,
pWt = 1,
esinw = TRUE,
standardize = TRUE,
genplot = FALSE,
verbose = FALSE
)
etp_2 <- astrochron::etp(
tmin = 0,
tmax = 1500,
dt = 1,
eWt = 1,
oWt = 0.5,
pWt = 1.5,
esinw = TRUE,
standardize = TRUE,
genplot = FALSE,
verbose = FALSE
)
etp_1[, 2] <- etp_1[, 2] + wr_coloured_noise(
nrow(etp_1),
sd = sd(etp_1[, 2]) / 1.5,
mean = mean(etp_1[, 2]),
phi = 0.9
)
etp_2[, 2] <- etp_2[, 2] + wr_coloured_noise(
nrow(etp_2),
sd = sd(etp_2[, 2]) / 1.5,
mean = mean(etp_2[, 2]),
phi = 0.9
)
X_wavelet_etp <- analyse_Xwavelet(
data_1 = etp_1,
data_2 = etp_2,
upperPeriod = 1024,
lowerPeriod = 2,
omega_nr = 8,
verbose = FALSE
)
plot_Xwavelet(Xwavelet = X_wavelet_etp, lowerPeriod = 2, upperPeriod = 1024,
n.levels = 100, palette_name = "rainbow", color_brewer = "grDevices",
useRaster = TRUE, periodlab = "Period (metres)", x_lab = "depth (metres)",
keep_editable = FALSE, dev_new = TRUE, plot_dir = TRUE,
plot_arrows = TRUE,
pwr_quant = 0.85,
n_arrows = 50,
T_unit = NULL,
P_unit = NULL,
arrow_length = 0.1,
arrow_lwd = 2,
arrow_angle = 25,add_lines = NULL, add_points = NULL, add_abline_h = NULL,
add_abline_v = NULL, add_data = TRUE, add_avg = FALSE, plot_horizontal = TRUE)
# }