Put legend and labels to dtwclust plot

668 views Asked by At

I used the dtwclust package in R to obtain the clusters in the picture.

dtw_cluster2 = tsclust(transdatawide2, type="partitional",k=4,preproc = zscore,
                  distance="dtw_basic",centroid = "pam",trace=T)

plot(dtw_cluster2)

clusters

I want to change the label x, where the numbers appear for the real dates and also add the legend to know which time series correspond to what. Do you know how to do it?

head(transdatawide2)

     2015-01-06  2015-02-03  2015-03-02  2015-03-03
 A    0.00000    0.00000        0.0      0.00000
 B    0.10000    0.10000        0.1      0.00000
1

There are 1 answers

1
Amit Gupta On

Use labs.arg argument. You can find more details here dtwclust documentation

with the plot(dtw_cluster2) + labs(title = "New plot title", x = "New x label")

or you can also use plot(dtw_cluster2) + xlab("New x label")+ ylab("New x label") + ggtitle("New plot title")

Hope this is useful