Lay out panels in a calendar format

facet_calendar(
  date,
  format = "%b %d",
  week_start = getOption("lubridate.week.start", 1),
  nrow = NULL,
  ncol = NULL,
  scales = "fixed",
  shrink = TRUE,
  dir = "h",
  labeller = "label_value",
  strip.position = "top"
)

Arguments

date

A variable that contains dates or an expression that generates dates will be mapped in the calendar.

format

A character string, such as %Y-%b-%d and %a (%d), formatting the display of facet strips. See ?strptime for details.

week_start

Day on which week starts following ISO conventions - 1 means Monday (default), 7 means Sunday. You can set lubridate.week.start option to control this parameter globally.

nrow, ncol

Number of rows and columns defined for "monthly" calendar layout. If NULL, it computes a sensible layout.

scales

Should scales be fixed ("fixed", the default), free ("free"), or free in one dimension ("free_x", "free_y")?

shrink

If TRUE, will shrink scales to fit output of statistics, not raw data. If FALSE, will be range of raw data before statistical summary.

dir

Direction of calendar: "h" for horizontal (the default) or "v" for vertical.

labeller

A function that takes one data frame of labels and returns a list or data frame of character vectors. Each input column corresponds to one factor. Thus there will be more than one with vars(cyl, am). Each output column gets displayed as one separate line in the strip label. This function should inherit from the "labeller" S3 class for compatibility with labeller(). You can use different labeling functions for different kind of labels, for example use label_parsed() for formatting facet labels. label_value() is used by default, check it for more details and pointers to other options.

strip.position

By default, the labels are displayed on the top of the plot. Using strip.position it is possible to place the labels on either of the four sides by setting strip.position = c("top", "bottom", "left", "right")

Details

A monthly calendar is set up as a 5 by 7 layout matrix. Each month could extend over six weeks but in these months is to wrap the last few days up to the top row of the block.

See also

frame_calendar for a compact calendar display, by quickly transforming the data.

Examples

# \donttest{ fs <- hourly_peds %>% dplyr::filter(Date < as.Date("2016-05-01")) fs %>% ggplot(aes(x = Time, y = Hourly_Counts)) + geom_line(aes(colour = Sensor_Name)) + facet_calendar(~ Date, nrow = 2) + # or ~ as.Date(Date_Time) theme(legend.position = "bottom")
# }