Learn R Programming

dtw (version 1.4-3)

dtwPlotTwoWay: Plotting of dynamic time warp results: pointwise comparison

Description

Plot a DTW results for visual inspection.

Usage

dtwPlotTwoWay(d,xts=NULL,yts=NULL, offset=0,
			type="o",pch=21, 
			xlab="Index", ylab="Query value", 
			match.col="gray70",
			... )

Arguments

d
an alignment result, object of class dtw
xts
query vector
yts
template vector
xlab,ylab
axis labels
offset
displacement between the timeseries, summed to template
match.col
color of the match lines
type,pch
graphical parameters for timeseries plotting, passed to matplot
...
additional arguments, passed to matplot

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.

The two vectors are displayed via the matplot functions, and their appearance can be customized via type and pch arguments (constants or vectors of two elements). If offset is set, the template is offset by the given amount; this will be reflected by the right-hand axis.

Only single-variate time series can be plotted this way.

See Also

dtwPlot for other dtw plotting functions, matplot for graphical parameters.

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,step=asymmetricP1)->alignment;


## Equivalent to plot(alignment,xts=query,yts=template,type="two");
dtwPlotTwoWay(alignment,xts=query,yts=template);

## Beware of the template's y axis, may be confusing
plot(alignment,xts=query,yts=template,offset=-2,type="two");

legend("topright",c("Query","Template"), pch=21, col=1:6)

Run the code above in your browser using DataLab