scale_x_ts: Position scales for time series data

View source: R/scale-x-ts.R

scale_x_tsR Documentation

Position scales for time series data

Description

Alters the appearance of the x-axis when plotting time series data. Can be used with annual, quarterly, and monthly frequency data. For annual data, tick marks will be drawn at the beginning and ending of each year with the label for the year centered below that interval. When used with quarterly data, smaller tick marks are added to show end of each quarter. The option for monthly data includes smaller tick marks for the first and second months of each quarter.

Usage

scale_x_ts(
  freq = "annual",
  show_years = "even",
  name = waiver(),
  limits = NULL,
  expand = waiver(),
  guide = waiver(),
  tick_width = 1L,
  tick_color = c("black", "gray", "gray"),
  tick_length = 4L,
  ...
)

Arguments

freq

Character scalar that determines the type of x-axis to be displayed. Options are 'annual' (the default), 'quarterly', and 'monthly'.

show_years

Character scaler indicating which years to display on the x-axis as labels. Options include: 'all', 'odd', and 'even'.

name

Character vector specifying the name of the axis to be displayed below the axis

limits

Date vector with two elements giving the minimum and maximum values to be shown on the x-axis.

tick_color

Vector of colors for the tick marks. Up to three values can be provided. The first is the color of the annual ticks, the second is the color of the quartly ticks and the thrid is the monthly tick color. If only one color is provided, all the tick marks will have the same color. Default value is c('black', 'gray', 'gray').

tick_length

A scalar number determining the length of the annual tick. Default value is 4L, which means the tick takes up 4 percent of the lenght of the y-axis (the unit used is always 'npc').


kbrevoort/kpbtemplates documentation built on May 31, 2024, 12:29 p.m.