tinyplot Method for Plotting ts Objects (Time Series)

Description

Convenience interface for visualizing ts (time series) objects with tinyplot.

Usage

## S3 method for class 'ts'
tinyplot(
  x,
  facet,
  type = "l",
  facet.args = list(free = TRUE),
  xlab = NULL,
  ylab = NA,
  ...
)

Arguments

x an object of class “ts”.
facet specification of facet for tinyplot.formula. The default in the tinyplot method is to use facet = NULL for univariate series and facet = ~ Series (equivalent to facet = “by”) for multivariate series.
type, facet.args, xlab, ylab, further arguments passed to tinyplot.

Details

Internally the time series object is converted to a long data frame with columns Time (time index), Value (observations), and Series (factor with column labels). Depending on the settings of facet this data frame is visualized either with the formula Value ~ Time or Value ~ Time | Series. See the facet argument description for more details and the Examples below for some illustrations.

An exception is made if the user explicitly supplies a distribution type argument (i.e, one of “histogram”, “density”, “boxplot”, “violin”, “qq”, “ridge”, or “rug”). These summarize the series values and ignore the time index, so they are visualized with the one-sided formula ~ Value (or ~ Value | Series for multivariate series). This preserves base-R-compatible behaviour such as tinyplot(Nile, type = “histogram”).

Value

No return value, called for the side effect of producing a plot.

Examples

library("tinyplot")

## univariate series
tinyplot(Nile)

# exception: expicitly passing a distribution type on a univariate series
# still triggers the corresponding transformation
tinyplot(Nile, type = "histogram")

## multivariate series (generally, these also look better with a theme)
tinytheme("clean2")
tinyplot(EuStockMarkets)                    ## faceted, free scales, same color

tinyplot(EuStockMarkets, facet.args = NULL) ## faceted, same scale, same color

tinyplot(EuStockMarkets, facet = "by")      ## faceted, free scales, diff colors

tinyplot(EuStockMarkets, facet = NULL)      ## single frame, diff colors

## further variations
tinyplot(EuStockMarkets, facet = NULL, legend = list("direct", repel = TRUE))

tinyplot(EuStockMarkets, facet = "by", facet.args = NULL)

tinyplot(EuStockMarkets, facet.args = list(free = TRUE, ncol = 1))

## pass additional tinyplot args through `...` for further customization
tinyplot(EuStockMarkets,
         facet.args = NULL,
         type = "area", xlab = NA, yaxl = ",",
         main = "European stock indices")

tinytheme() ## reset