Skobo Do
Skobo Do

Reputation: 59

How to plot with dtaidistance

I tried an example using dtaidistance and dtw, but it did not plot the result.

from dtaidistance import dtw
from dtaidistance import dtw_visualisation as dtwvis
import numpy as np
s1 = np.array([0., 0, 1, 2, 1, 0, 1, 0, 0, 2, 1, 0, 0])
s2 = np.array([0., 1, 2, 3, 1, 0, 0, 0, 2, 1, 0, 0, 0])
path = dtw.warping_path(s1, s2)
dtwvis.plot_warping(s1, s2, path, filename="warp.png")

It should have looked like this:

enter image description here

Unfortunately, it did not show up.

I tried to add "plt.show()" at the end of the code (previously importing pyplot of course). But, in this case, it has not helped.

What is the reason it does not plot the graph, like in the example above?

Upvotes: 0

Views: 585

Answers (2)

boebelix
boebelix

Reputation: 11

Delete the filename, then you can reach the output with plt.show()

figure, axes = dtwvis.plot_warping(s1, s2, path)

figure.show()

Upvotes: 1

Skobo Do
Skobo Do

Reputation: 59

The picture in the example is not meant to be plotted within python but saved as .png to hard drive where the python code is stored.

Upvotes: 0

Related Questions