dtaidistance.dtw_visualisation

Dynamic Time Warping (DTW) visualisations.

author:Wannes Meert
copyright:Copyright 2017-2022 KU Leuven, DTAI Research Group.
license:Apache License, Version 2.0, see LICENSE for details.
dtaidistance.dtw_visualisation.plot_average(s1, s2, avg, path1, path2, filename=None, fig=None, ax=None)

Plot how s1 and s2 relate to the avg.

Parameters:
  • s1 – Seq 1.
  • s2 – Seq 2.
  • path – Average sequence.
  • filename – Filename path (optional).
  • fig – Matplotlib Figure object
  • ax – Matplotlib axes.Axes object
Returns:

Figure, axes.Axes

dtaidistance.dtw_visualisation.plot_warp(from_s, to_s, new_s, path, filename=None, fig=None, axs=None)

Plot the warped sequence and its relation to the original sequence and the target sequence.

Parameters:
  • from_s – From sequence.
  • to_s – To sequence.
  • new_s – Warped version of from sequence.
  • path – Optimal warping path.
  • filename – Filename path (optional).
  • fig – Matplotlib Figure object
  • axs – Array of Matplotlib axes.Axes objects (length == 3)
Returns:

Figure, list[Axes]

dtaidistance.dtw_visualisation.plot_warping(s1, s2, path, filename=None, fig=None, axs=None, series_line_options=None, warping_line_options=None)

Plot the optimal warping between to sequences.

Parameters:
  • s1 – From sequence.
  • s2 – To sequence.
  • path – Optimal warping path.
  • filename – Filename path (optional).
  • fig – Matplotlib Figure object
  • axs – Array of Matplotlib axes.Axes objects (length == 2)
  • series_line_options – Dictionary of options to pass to matplotlib plot None will not pass any options
  • warping_line_options – Dictionary of options to pass to matplotlib ConnectionPatch None will use {‘linewidth’: 0.5, ‘color’: ‘orange’, ‘alpha’: 0.8}
Returns:

Figure, list[Axes]

dtaidistance.dtw_visualisation.plot_warping_single_ax(s1, s2, path, filename=None, fig=None, ax=None)

Plot the optimal warping between to sequences.

Parameters:
  • s1 – From sequence.
  • s2 – To sequence.
  • path – Optimal warping path.
  • filename – Filename path (optional).
  • fig – Matplotlib Figure object
  • ax – Matplotlib axes.Axes object
Returns:

Figure, Axes

dtaidistance.dtw_visualisation.plot_warpingpaths(s1, s2, paths, path=None, filename=None, shownumbers=False, showlegend=False, figure=None, matshow_kwargs=None)

Plot the warping paths matrix.

Parameters:
  • s1 – Series 1
  • s2 – Series 2
  • paths – Warping paths matrix
  • path – Path to draw (typically this is the best path)
  • filename – Filename for the image (optional)
  • shownumbers – Show distances also as numbers
  • showlegend – Show colormap legend
  • figure – Matplotlib Figure object
Returns:

Figure, Axes