plot_catch: Plot catch data over time

View source: R/catches.R

plot_catchR Documentation

Plot catch data over time

Description

Functions for plotting catch data over time as a stacked bar plot.

Usage

tidy_catch(dat, areas = NULL, ...)

plot_catch(
  dat,
  french = FALSE,
  ylab = en2fr("Catch", french),
  xlim = c(1954, 2017),
  units = NULL,
  unreliable = c(1996, 2006),
  blank_plot = FALSE
)

set_fishing_year(
  dat,
  month_fishing_starts = 1,
  day_fishing_starts = 1,
  yr_col = "year",
  date_col = "best_date",
  ...
)

Arguments

dat

Input data frame. For tidy_catch() should be from gfdata::get_catch(). For plot_catch() should be from tidy_catch() or be formatted similarly. See details.

areas

Fisheries and Oceans major statistical areas (eg. 3C, 3D, 5A, 5B, etc.). See gfplot::pbs_areas for a lookup table with descriptions. Enter as a regular expression. For example, c("5A", "5B") or c("5[CDE]+", "5[AB]+").

...

Absorb unused parameters

french

Logical for French or English.

ylab

Y axis label.

xlim

X axis limits in years.

units

A named character vector with names referring to text that will be pasted into the y-axis label and a value defining the quantity to divide the value column by for that unit label. Defaults to c('1000 t' = 1000000, 't' = 1000, 'kg' = 1) if units = NULL.

unreliable

An optional numeric vector defining years before which the data are less reliable. Leave as NA to omit.

blank_plot

If TRUE then a blank plot with appropriate axes will be returned. Used in the synopsis report.

month_fishing_starts

The month in which the fishing year starts and ends. The year column of the returned data frame will refer to the fishing year as determined by this and the day_fishing_starts argument.

day_fishing_starts

The day of the month in which the fishing year starts and ends. See month_fishing_starts

yr_col

Name of the column in dat holding the fishing year data

date_col

Name of the column in dat holding the date data

Details

  • tidy_catch() Prepares PBS data for plot_catch(). This works across one or multiple species. * plot_catch() Plots catch. The input data frame must come from tidy_catch() or have the columns (in any order): year, gear, value (containing catches or landings).

Value

The data frame dat with modified year data

Examples

## Not run: 
d <- gfdata::get_catch("lingcod")
tidy_catch(d, areas = c("5[CDE]+", "5[AB]+", "3[CD]+")) %>%
  plot_catch()

tidy_catch(d, areas = c("5A", "5B")) %>%
  plot_catch()

## End(Not run)
## Not run: 
d <- gfdata::get_catch("arrowtooth flounder")
d <- set_fishing_year(d, 2, 21) # Feb 21 - Feb 20 is the fishing year

## End(Not run)

seananderson/gfplot documentation built on May 6, 2024, 2:22 p.m.