Add a date scale and custom formatting for creating consistent timeseries plots.

custom_datetimeScale(
  startdate = NULL,
  enddate = NULL,
  timezone = NULL,
  expand = c(0, 0.05),
  break_width = NULL,
  minor_break_width = NULL,
  date_labels = "%b %d",
  tick_location = c("midnight", "midday"),
  includeFullEnddate = TRUE,
  today_label = TRUE,
  ...
)

Arguments

startdate

Desired start date (integer or character in ymd format or POSIXct).

enddate

Desired end date (integer or character in ymd format or POSIXct).

timezone

Timezone for label formatting.

expand

Vector of range expansion constants used to add some padding around the data, to ensure that they are placed some distance away from the axes.

break_width

Space between breaks. If NULL, suitable breaks are calculated based on the data. See 'Details'.

minor_break_width

Space between minor breaks. If NULL, suitable breaks are calculated based on the data. See 'Details'.

date_labels

date format string for formatting date labels.

tick_location

Location of ticks ("midnight" or "midday")

includeFullEnddate

if TRUE, the x-axis limit is pushed up to include the full final day.

today_label

if FALSE, no label will be generated for today.

...

Additional arguments passed onto scale_x_datetime.

Details

break_width and minor_break_width can be specified in several ways.

  • A number, taken to be in days

  • An object of class difftime

  • A character string, containing one of "day", "week", "month", "quarter" or "year". This can optionally be preceded by a (positive or negative) integer and a space or followed by "s". For example: "3 weeks".