tinyplot.zoo: Plotting zoo Objects with tinyplot

View source: R/tinyplot.zoo.R

tinyplot.zooR Documentation

Plotting zoo Objects with tinyplot

Description

The approach is similar to that in autoplot.zoo (based on ggplot2) and uses fortify.zoo (with melt = TRUE) to convert the zoo object into a data frame and then uses a suitable formula to visiualize the series.

Usage

  ## S3 method for class 'zoo'
tinyplot(object, facet, type = "l",
    facet.args = list(free = TRUE), ylab = "", ...)

Arguments

object

an object of class "zoo".

facet

specification of facet for tinyplot.formula. The default in the tinyplot method is to use facet = NULL for univariate series and facet = ~ Series for multivariate series.

type, facet.args, ylab, ...

further arguments passed to tinyplot.

Details

Convenience interface for visualizing zoo objects with tinyplot.

See Also

tinyplot, autoplot.zoo

Examples

if(require("tinyplot")) {
suppressWarnings(RNGversion("3.5.0"))
set.seed(1)

## example data
x.Date <- as.Date(paste(2003, 02, c(1, 3, 7, 9, 14), sep = "-"))
x <- zoo(rnorm(5), x.Date)
xlow <- x - runif(5)
xhigh <- x + runif(5)
z <- cbind(x, xlow, xhigh)

## univariate plotting
tinyplot(x)

## multivariate plotting in multiple or single panels
tinyplot(z)                    ## multiple without color/linetype with free scales
tinyplot(z, facet.args = NULL) ## multiple without color/linetype with same scale
tinyplot(z, facet = ~ Series)  ## multiple with series-dependent color/linetype
tinyplot(z, facet = NULL)      ## single with series-dependent color/linetype

## by hand with color/linetype and with/without facets
d <- fortify.zoo(z, melt = TRUE)
tinyplot(Value ~ Index | Series, data = d, type = "l")
tinyplot(Value ~ Index | Series, facet = "by", data = d, type = "l")
tinyplot(Value ~ Index | Series, facet = "by", data = d, type = "l", facet.args = list(free = TRUE))

## EuStockMarkets data (coerced from "ts")
eusm <- as.zoo(EuStockMarkets)
tinyplot(eusm)
tinytheme("clean2")
tinyplot(eusm, facet = NULL)
tinyplot(eusm, facet = ~ Series)
tinyplot(eusm, facet = ~ Series, facet.args = NULL)
tinytheme() ## reset

}

zoo documentation built on March 3, 2025, 3:01 p.m.