View source: R/ct_plot_calendar.R
| ct_plot_calendar | R Documentation |
Visualises a year of camera-trap records as a calendar heatmap. Tiles are shaded by the number of records per day, or by the summed value of a chosen column. A count distribution can optionally be fitted to the daily values and used for the shading.
ct_plot_calendar(
data,
datetime,
format = NULL,
size_column = NULL,
only_month = NULL,
fit_distribution = FALSE,
abbreviate_month_name = FALSE,
month_name = NULL,
day_name = NULL,
number_of_column = 4,
low = NULL,
high = NULL,
palette = NULL,
na_value = "grey95",
show_day_number = TRUE,
title = NULL
)
data |
A data frame of records, one row per detection. |
datetime |
Column holding the date or date-time of each record. |
format |
Optional date format(s) passed to |
size_column |
Optional column whose values are summed per day, for example the number of individuals recorded in each detection. If omitted, the number of records (detections) per day is used instead. |
only_month |
Optional integer vector of month numbers (1 to 12) to keep,
for example |
fit_distribution |
Logical. If |
abbreviate_month_name |
Logical. Use three-letter month names. Ignored
when |
month_name |
Optional length-12 character vector of month labels, for localisation. Defaults to the English month names. |
day_name |
Optional length-7 character vector of weekday labels, Monday
first. Defaults to |
number_of_column |
Number of month panels per row. Default |
low, high |
Optional start and end colours for a two-colour gradient
fill. When both are supplied they override |
palette |
Optional fill palette. Either a single viridis option letter
(for example |
na_value |
Fill colour for days with no records. Default |
show_day_number |
Logical. Print the day number inside each tile.
Default |
title |
Optional plot title. Generated automatically when |
With fit_distribution = FALSE the calendar is an activity map: tiles are
shaded by the records per day (or the summed size_column), so busier days
are brighter.
With fit_distribution = TRUE the calendar is instead a typicality map. A
single distribution is fitted to the whole displayed period, and each tile is
shaded by the fitted probability of that day's count. Because most days have
no detection, the count of zero is the most probable value, so empty days
receive the highest density and the brightest colour, while the rarer busy
days appear darker. The map highlights how typical or
unusual each day is under the model, rather than how much activity occurred.
Use fit_distribution = FALSE if you want activity intensity instead.
A ggplot2::ggplot object.
ct_fit_distribution(), ct_plot_camtrap_activity()
library(dplyr)
data(ACBR)
# The calendar covers one year at a time, so keep a single year.
d2024 <- ACBR$acbr_data %>%
# Filter to independent (10min separated) detections
ct_independence(species_column = species,
datetime = datetime,
format = "%Y-%m-%d %H:%M:%S",
threshold = 10*60
) %>%
# Select data for 2025 year
filter(lubridate::year(datetime) == 2025)
ct_plot_calendar(d2024, datetime = datetime,
size_column = count,
low = "gray", high = "red"
)
#'
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.