bcat_plt_ts: Time series plot utility

View source: R/bcat_plt_ts.R

bcat_plt_tsR Documentation

Time series plot utility

Description

Create a time series visualization with UC styling. Supports decomposition into trend/seasonal/remainder, ACF/PACF display, and recession shading.

Usage

bcat_plt_ts(
  df,
  x = NULL,
  y = NULL,
  color = NULL,
  decompose = FALSE,
  acf = FALSE,
  recession_bars = NULL,
  x_lab = ggplot2::waiver(),
  y_lab = ggplot2::waiver(),
  title = ggplot2::waiver(),
  subtitle = ggplot2::waiver(),
  caption = ggplot2::waiver(),
  legend_lab = ggplot2::waiver(),
  legend_position = "bottom",
  legend_hide = FALSE,
  x_scale = NULL,
  y_scale = NULL,
  color_scale = scale_colour_UC(),
  layer_points = FALSE,
  x_highlight_min = NULL,
  x_highlight_max = NULL,
  y_refline = NULL
)

Arguments

df

A data frame with date and value columns.

x

Date column.

y

Value column.

color

Variable for color aesthetic.

decompose

Logical. Show 4-panel decomposition? Default is FALSE.

acf

Logical. Show ACF/PACF side-by-side? Default is FALSE.

recession_bars

Data frame with start and end date columns. Default is NULL.

x_lab

Label for x-axis.

y_lab

Label for y-axis.

title

Plot title.

subtitle

Plot subtitle.

caption

Plot caption.

legend_lab

Legend title.

legend_position

Legend position.

legend_hide

Logical. Hide legend?

x_scale

scale_x_ function.

y_scale

scale_y_ function.

color_scale

scale_color_ function.

layer_points

Logical. Show points on line? Default is FALSE.

x_highlight_min

Date(s) at which to start highlight region(s).

x_highlight_max

Date(s) at which to end highlight region(s).

y_refline

Horizontal reference line(s).

Value

A ggplot or patchwork object.

Author(s)

Saannidhya Rawat

See Also

Other plots: bcat_plt_area(), bcat_plt_bar(), bcat_plt_box(), bcat_plt_coef(), bcat_plt_diag(), bcat_plt_hist(), bcat_plt_line(), bcat_plt_point()

Examples

library(ggplot2)
library(scales)

bcat_plt_ts(economics, x = date, y = unemploy,
            y_scale = scale_y_continuous(labels = comma_format()))

Rbearcat documentation built on March 21, 2026, 5:07 p.m.