birdnet_barchart: Plot stacked barcharts of BirdNET detections

View source: R/birdnet_barchart.R

birdnet_barchartR Documentation

Plot stacked barcharts of BirdNET detections

Description

Plot stacked barcharts of user-selected BirdNET results by date

Usage

birdnet_barchart(
  data,
  julian.breaks,
  y.limits,
  interactive = FALSE,
  focal.species,
  focal.colors
)

Arguments

data

Data.table or data.frame of formatted BirdNET results that a user would like to plot. Generally, this data object may be preceded by a call to add_time_cols; all data should come from a single site and the object must contain columns named "locationID" (character), "recordingID" (character), and "dateTimeLocal" (POSIXct).

julian.breaks

Optional numeric vector of julian date plotting breaks to use on the x axis. If omitted, will be computed automatically. Example inputs: c(140, 160, 180) would graph 3 breaks on the x axis (May 20, June 9, and June 29 for non-leap year data); c(130:160) would graph every single date from May 10 to June 9 on the x axis (for non-leap year data). See also readable_julian_breaks. Please start with 1 for the first day of the year rather than 0.

y.limits

Optional numeric vector to control y-axis limits (e.g., c(0, 150)). If not entered, will be generated automatically.

interactive

Default = FALSE for a static plot. If true, produces a plotly plot with interactive hover.

focal.species

Optional character vector containing the common names of species to highlight. Any species contained in the data object that are not contained in focal.species will be plotted under one color as "Other".

focal.colors

Optional character vector describing the colors that should be used for species named in the focal.species argument. Non-focal species ("Other") will be plotted in black.

Details

This function was developed by the National Park Service Natural Sounds and Night Skies Division. It is intended to provide exploratory plotting for summarizing and visualizing BirdNET results.

Generally, interactive = FALSE should be used in conjunction with the focal.species argument. If focal.species argument is provided, a legend will also be plotted.

Use of interactive = TRUE is meant strictly for exploratory purposes. If focal.species argument is not used, no legend will be plotted. A typical use case is to omit focal.species when setting interactive = TRUE.

Value

Stacked barchart of BirdNET results

See Also

birdnet_heatmap

Examples

## Not run: 

# Read in example data
data(exampleHeatmapData)

# Ensure your data has an appropriate recordingID column and time columns
dat <- exampleHeatmapData
dat[ ,recordingID := basename(filepath)]
dat <- add_time_cols(
 dt = dat,
 tz.recorder = 'America/Los_angeles',
 tz.local = 'America/Los_angeles'
)

# Produce an interactive plotly barchart with interactive = TRUE
birdnet_barchart(data = dat, interactive = TRUE)

# Produce a static ggplot barchat with interactive = FALSE,
# add focal.species with custom colors (any species in the data object
# that are not in focal.species will be plotted in black as "Other".)
birdnet_barchart(
   data = dat,
   interactive = FALSE,
   focal.species = c("Pacific Wren", "Swainson's Thrush"),
   focal.colors = c('#00BE67', '#C77CFF', '#c51b8a')
)


## End(Not run)


nationalparkservice/NSNSDAcoustics documentation built on March 4, 2025, 10:24 p.m.