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 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, 7 means Sunday (default). 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 formulae of the type ~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(). See label_value() 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

fs <- pedestrian %>% 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) + theme(legend.position = "bottom")