tinyplot.zoo | R Documentation |
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.
## S3 method for class 'zoo'
tinyplot(object, facet, type = "l",
facet.args = list(free = TRUE), ylab = "", ...)
object |
an object of class |
facet |
specification of |
type , facet.args , ylab , ... |
further arguments passed to |
Convenience interface for visualizing zoo objects with tinyplot.
tinyplot
, autoplot.zoo
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
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.