cavity_plot: Plot light data

View source: R/plot.R

cavity_plotR Documentation

Plot light data

Description

Plot light data patterns, optionally with overlayed detected sunrise/sunset events and bouts of cavity use.

Usage

cavity_plot(
  data,
  cavity = NULL,
  sun = NULL,
  loc = NULL,
  days = 10,
  start = NULL,
  tz_apply_offset = TRUE,
  nrow = NULL,
  ncol = NULL,
  clip = TRUE,
  show_night = TRUE
)

Arguments

data

Data frame. Raw light data. Requires two columns: "time" and "light"

cavity

Data frame. Bouts of cavity use, output from cavity_detect.

sun

Data frame. sun Data frame. Detected sunrise and sunset events, output of sun_detect

loc

Numeric vector. Optional Longitude and Latitude of the observations (if not in the data, this must be provided if show_night = TRUE).

days

Numeric. Number of days to plot

start

Character. Start date in "YYYY-MM-DD" format

tz_apply_offset

Logical. Apply a timezone offset to indicate local time on the x-axis. Only relevant if plotting light data alone.

nrow

Numeric. For multi-day figures, number of plot rows.

ncol

Numeric. For multi-day figures, number of plot cols.

clip

Logical. For geolocator light data >64 lux, clip the data to a max of 64? This sometimes makes patterns easier to see.

show_night

Logical. Overlay grey shading to indicate nighttime (defined by local sunrise/sunset times calculated from coordinates).

Value

A ggplot2 figure showing light patterns overlayed with detected sunrise/sunset events and/or bouts of cavity use.

Examples


# Light data only
cavity_plot(flicker, days = 1)

# Don't offset time to show local (i.e. leave as UTC)
cavity_plot(flicker, days = 4, tz_apply_offset = FALSE)

# Light data + sunrise/sunset
s <- sun_detect(flicker)
cavity_plot(flicker, sun = s, days = 1)

# Light data + sunrise/sunset + cavity use
s <- sun_detect(flicker)
e <- cavity_detect(flicker, sun = s)
cavity_plot(flicker, cavity = e, sun = s, days = 1)

# Multi-day plots
cavity_plot(flicker, days = 3)
cavity_plot(flicker, days = 5, nrow = 1)
cavity_plot(flicker, days = 5, ncol = 1)

# With clipping
cavity_plot(wtsp, days = 1)

# Without clipping
cavity_plot(wtsp, days = 1, clip = FALSE)

# Remove nights
cavity_plot(wtsp, days = 1, show_night = FALSE)



steffilazerte/cavityuse documentation built on Aug. 4, 2022, 11:22 p.m.