ts_plot: Plot Time Series

Description Usage Arguments Details See Also Examples

View source: R/ts_plot.R

Description

ts_plot() is a fast and simple plotting function for ts-boxable time series, with limited customizability. For more theme options, use ts_ggplot().

Usage

1
2
ts_plot(..., title, subtitle, ylab = "", family = getOption("ts_font",
  "sans"))

Arguments

...

ts-boxable time series, objects of class ts, xts, data.frame, data.table, or tibble.

title

title (optional)

subtitle

subtitle (optional)

ylab

ylab (optional)

family

font family (optional, can also be set via options)

Details

Both ts_plot() and ts_ggplot() combine multiple ID dimensions into a single dimension. To plot multiple dimensions in different shapes, facets, etc., use standard ggplot.

Limited customizability of ts_plot is available via options. See examples.

See Also

ts_ggplot(), for a plotting function based on ggplot2. ts_dygraphs(), for interactive time series plots. ts_save() to save a plot to the file system.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
ts_plot(
  AirPassengers, 
  title = "Airline passengers",
  subtitle = "The classic Box & Jenkins airline data"
)
 
# naming arguments
ts_plot(total = ldeaths, female = fdeaths, male = mdeaths)

# using different ts-boxable objects
ts_plot(ts_scale(ts_c(
  ts_xts(airmiles), 
  ts_tbl(co2), 
  JohnsonJohnson, 
  ts_df(discoveries)
)))

# customize ts_plot
op <- options(
  tsbox.lwd = 3, 
  tsbox.col = c("gray51", "gray11"), 
  tsbox.lty = "dashed"
)
ts_plot(
  "Female" = fdeaths,
  "Male" = mdeaths
)
options(op)  # restore defaults

christophsax/tsbox documentation built on June 26, 2018, 1:13 p.m.