Learn R Programming

dtwclust (version 1.3.0)

plot-dtwclust: Plot the result of dtwclust

Description

Plots the time series of each cluster along with the obtained centroid. It uses ggplot2 plotting system.

Usage

## S3 method for class 'dtwclust,missing':
plot(x, y, ..., clus = seq_len(x@k),
  labs.arg = NULL, data = NULL, time = NULL, plot = TRUE)

Arguments

x
An object of class dtwclust-class as returned by dtwclust.
y
Ignored.
...
Further arguments to pass to geom_line for the plotting of the cluster centers. Default values are: linetype = "dashed", size = 1.5, colour = "black"
clus
A numeric vector indicating which clusters to plot.
labs.arg
Arguments to change the title and/or axis labels. See labs for more information
data
The data in the same format as it was provided to dtwclust.
time
Optional values for the time axis. If series have different lengths, provide the time values of the longest series.
plot
Logical flag. You can set this to FALSE in case you want to save the ggplot object without printing anything to screen

Value

  • A gg object invisibly.

Details

The flag save.data should be set to TRUE when running dtwclust to be able to use this. Optionally, you can manually provide the data in the data parameter.

The function returns the gg object invisibly, in case you want to modify it to your liking. You might want to look at ggplot_build if that's the case.

See Also

dtwclust-class, dtwclust, ggplot