asardaes / dtwclust

R Package for Time Series Clustering Along with Optimizations for DTW
https://cran.r-project.org/package=dtwclust
GNU General Public License v3.0
252 stars 29 forks source link

How to plot univariate trajectories from multivariate clustering? #67

Closed maellecoursonnais closed 4 months ago

maellecoursonnais commented 7 months ago

Hello,

I carry a multivariate time series clustering, and your package makes it very easy to do so. However, I'd like to plot the univariate time series (i.e., the different columns) separately with plot.TSClusters. I could not find anything in the documentation of the function about this.

Here's a reproducible example:

library(dtwclust)
data("uciCT")

mvc <- tsclust(CharTrajMV, k = 4L, distance = "gak", seed = 390L)
plot(mvc, type = "series")

image

From what I understand, the time series cluster plot are somewhat summarizing the multivariate time series, but I'd like to separate them out.

Cheers

asardaes commented 7 months ago

You can't do that with the included method, it is only meant as a generic plot to handle the most common scenarios, if you need anything more sophisticated you're probably better off implementing your own logic, maybe the source code can serve as reference:

https://github.com/asardaes/dtwclust/blob/5f9f16856629dda615a3b19efc91e705c7ef1393/R/S4-TSClusters-methods.R#L582