Learn R Programming

dtw (version 1.4-3)

dtwPlotThreeWay: Plotting of dynamic time warp results: annotated warping function

Description

Plot a DTW results for visual inspection.

Usage

dtwPlotThreeWay(d,xts=NULL,yts=NULL,type.align="p",type.ts="l",
	       margin=4, inner.margin=0.2, title.margin=1.5,
	       xlab="Query index",ylab="Template index",main="Timeseries alignment",
			... )

Arguments

d
an alignment result, object of class dtw
xts
query vector
yts
template vector
xlab
label for the query axis
ylab
label for the template axis
main
main title
type.align
line style for alignment path plot
type.ts
line style for timeseries plot
margin
outer figure margin
inner.margin
inner figure margin
title.margin
space on the top of figure
...
additional arguments, passed to plotting functions

Warning

These functions are incompatible with mechanisms for arranging plots on a device: par(mfrow), layout and split.screen.

concept

Dynamic Time Warp

Details

Display the query and template time series and their alignment, arranged so that alignment can be visually inspected.

Only single-variate time series are supported, and they must be passed to the xts and yts arguments (query and template are not stored in the dtw object).

Examples

Run this code
## A noisy sine wave as query
## A cosine is for template; sin and cos are offset by 25 samples

idx<-seq(0,6.28,len=100);
query<-sin(idx)+runif(100)/10;
template<-cos(idx)
dtw(query,template,keep=TRUE)->alignment;


## Beware of the template's y axis, may be confusing
## Equivalent to plot(alignment,xts=query,yts=template,type="three");
dtwPlotThreeWay(alignment,xts=query,yts=template);

Run the code above in your browser using DataLab