Learn R Programming

PAMscapes (version 0.11.3)

plotAcousticScene: Plot Acoustic Scene

Description

Plots a representation of the acoustic scene using detections in data. Frequency ranges for detections are taken from user input and displayed as different colored bars

Usage

plotAcousticScene(
  x,
  freqMap = NULL,
  typeCol = "species",
  title = NULL,
  bin = "1day",
  by = NULL,
  combineYears = FALSE,
  effort = NULL,
  scale = c("log", "linear"),
  freqMin = NULL,
  freqMax = NULL,
  fill = TRUE,
  alpha = 1,
  returnData = FALSE,
  add = FALSE
)

Value

a ggplot object

Arguments

x

dataframe of detections, must have column UTC and a column to connect detection types to the frequency type map

freqMap

a dataframe listing frequency ranges to use for various detection types in x. Must have columns type, freqMin (Hz), freqMax (Hz), and optionally color (color to use for this type of detection on plot)

typeCol

column name in x that matches names in type column in freqMap

title

optional title to use for the plot

bin

time bin to use for plotting time axis. Each detection will be displayed as covering this amount of time

by

if not NULL, column name to facet plot by (e.g. site)

combineYears

logical flag to combine all observations to display as a single "year". The year will be set to 2019, and detections falling on leap days (February 29th) will be removed

effort

if not NULL, a dataframe decribing effort data to be be formatted with formatEffort

scale

one of log or linear, the frequency scale for the plot

freqMin

optional minimum frequency for plot, useful for log scale

freqMax

optional maximum frequency for plot

fill

logical flag if TRUE then filled boxes will be plotted, if FALSE then only outlines will be plotted

alpha

transparency percentage for plotting, values less than 1 will allow multiple overlapping colors to be seen

returnData

if TRUE then no plot will be generated, instead the dataframe that would normally be used to make the plot will be returned

add

logical flag if FALSE plots normally if TRUE then the output can be (maybe) added to an existing ggplot object

Author

Taiki Sakai taiki.sakai@noaa.gov

Examples

Run this code
detDf <- data.frame(
   UTC=as.POSIXct(c('2023-01-01 00:00:00',
                    '2023-01-03 00:00:00',
                    '2023-01-02 12:00:00',
                    '2023-01-04 00:00:00'),
                  tz='UTC'),
  species = c('Dolphin', 'Whale', 'Whale', 'Dolphin'))
freqMap <- data.frame(type=c('Dolphin', 'Whale'),
                      freqMin=c(10e3, 100),
                      freqMax=c(30e3, 400),
                      color=c('darkgreen', 'blue'))
plotAcousticScene(detDf, freqMap=freqMap, typeCol='species', bin='1day')

Run the code above in your browser using DataLab