xtsplot {dsa} | R Documentation |
Create a plot for xts series
Description
Creates a plot using an xts series
Usage
xtsplot(
xts,
transform = "none",
type = "line",
years = NA,
scale = 1,
names = NA,
color = NA,
main = "",
legend = NA,
textsize = 1,
textsize_x = NA,
textsize_y = NA,
textsize_legend = NA,
textsize_title = NA,
linesize = 1.1,
WeekOfYear = F,
date_breaks = NA,
date_labels = NA,
submain = NULL
)
Arguments
xts |
one or many series |
transform |
one of "none","diff", "change" (can be abbreviated) |
type |
either "bar", "bar2" or "line" |
years |
number of years to include |
scale |
by what factor should data be scaled. |
names |
change names of series |
color |
color of the series |
main |
title of the plot |
legend |
alignment of legend. "horizontal" or "vertical" |
textsize |
scale the size of all the text |
textsize_x |
scale size of x-axis labels |
textsize_y |
scale size of y-axis labels |
textsize_legend |
scale size of legend text |
textsize_title |
scale size of title |
linesize |
scale the size of the lines |
WeekOfYear |
should x axis be week of year |
date_breaks |
distance between labels (see examples) |
date_labels |
format of the date label for x-axis |
submain |
subtitle of the plot |
Details
This function uses the ggplot2 package. The difference between type="bar" and type="bar2" is that the former produces barcharts with bars of the second series in front of the bars of the first series (and accordingly for more than two series), while "bar2" creates side-by-side barcharts. If a scale is supplied, the data will be divided by this number.
Author(s)
Daniel Ollech
Examples
x <- xts::xts(rnorm(100), seq.Date(as.Date("2010-01-01"), length.out=100, by="months"))
y <- xts::xts(runif(100), seq.Date(as.Date("2010-01-01"), length.out=100, by="months"))
xtsplot(y, transform="diff", type="bar")
xtsplot(y, transform="diff", type="bar", date_breaks="24 months")
xtsplot(merge(x,y), names=c("Gaussian", "Uniform"), main="Simulated series")