Produces a time series seasonal plot. A seasonal plot is similar to a regular time series plot, except the x-axis shows data from within each season. This plot type allows the underlying seasonal pattern to be seen more clearly, and is especially useful in identifying years in which the pattern changes.

gg_season(
  data,
  y = NULL,
  period = NULL,
  facet_period = NULL,
  max_col = Inf,
  max_col_discrete = 7,
  pal = (scales::hue_pal())(9),
  polar = FALSE,
  labels = c("none", "left", "right", "both"),
  labels_repel = FALSE,
  labels_left_nudge = 0,
  labels_right_nudge = 0,
  ...
)

Arguments

data

A tidy time series object (tsibble)

y

The variable to plot (a bare expression). If NULL, it will automatically selected from the data.

period

The seasonal period to display.

facet_period

A secondary seasonal period to facet by (typically smaller than period).

max_col

The maximum number of colours to display on the plot. If the number of seasonal periods in the data is larger than max_col, the plot will not include a colour. Use max_col = 0 to never colour the lines, or Inf to always colour the lines. If labels are used, then max_col will be ignored.

max_col_discrete

The maximum number of colours to show using a discrete colour scale.

pal

A colour palette to be used.

polar

If TRUE, the season plot will be shown on polar coordinates.

labels

Position of the labels for seasonal period identifier.

labels_repel

If TRUE, the seasonal period identifying labels will be repelled with the ggrepel package.

labels_left_nudge, labels_right_nudge

Allows seasonal period identifying labels to be nudged to the left or right from their default position.

...

Additional arguments passed to geom_line()

Value

A ggplot object showing a seasonal plot of a time series.

References

Hyndman and Athanasopoulos (2019) Forecasting: principles and practice, 3rd edition, OTexts: Melbourne, Australia. https://OTexts.com/fpp3/

Examples

library(tsibble)
library(dplyr)
tsibbledata::aus_retail %>%
  filter(
    State == "Victoria",
    Industry == "Cafes, restaurants and catering services"
  ) %>%
  gg_season(Turnover)