Learn R Programming

DTSg (version 0.6.0)

plot.DTSg: Plot Time Series

Description

Displays an interactive plot of a DTSg object. This method requires dygraphs and RColorBrewer to be installed. Its main purpose is not to make pretty plots, but rather to offer a possibility to interactively explore time series. The title of the plot and the label of its primary axis are automatically generated out of the object's metadata (fields). See DTSg for further information.

Usage

# S3 method for DTSg
plot(
  x,
  from = first(self$values(reference = TRUE)[[".dateTime"]]),
  to = last(self$values(reference = TRUE)[[".dateTime"]]),
  cols = self$cols(class = "numeric"),
  secAxisCols = NULL,
  secAxisLabel = "",
  ...
)

Arguments

x

A DTSg object (S3 method only).

from

A POSIXct date with the same time zone as the time series or a character string coercible to one. The time series is plotted from this date on.

to

A POSIXct date with the same time zone as the time series or a character string coercible to one. The time series is plotted up to this date.

cols

A character vector specifying the columns whose values shall be plotted.

secAxisCols

An optional character vector specifying the columns whose values shall be plotted on a secondary axis. Must be a subset of cols.

secAxisLabel

A character string specifying the label of the optional secondary axis.

Not used (S3 method only).

Value

Returns a DTSg object.

See Also

DTSg, dygraph, POSIXct, cols

Examples

Run this code
# NOT RUN {
# new DTSg object
x <- DTSg$new(values = flow)

# plot time series
if (requireNamespace("dygraphs", quietly = TRUE) &&
    requireNamespace("RColorBrewer", quietly = TRUE)) {
  ## R6 method
  x$plot()

  ## S3 method
  plot(x = x)
}

# }

Run the code above in your browser using DataLab