plot_lengths: Plot length frequency data

View source: R/plot-lengths.R

plot_lengthsR Documentation

Plot length frequency data

Description

Functions for plotting length frequency data.

Usage

plot_lengths(
  dat,
  xlab = "Length (cm)",
  ylab = "Relative length frequency",
  fill_col = c(M = "grey80", F = "#FF000010"),
  line_col = c(M = "grey40", F = "red"),
  survey_cols = NULL,
  alpha = 0.24,
  survey_facets = NULL,
  bin_size = 2,
  min_total = 20,
  show_year = "even",
  french = FALSE
)

Arguments

dat

A data frame from tidy_lengths_raw() or tidy_lengths_weighted() or a similarly formatted data frame. Must have columns named survey, year, sex ("M" and "F"), length_bin, proportion, total (for the total number of samples for that year and survey/commercial combination).

xlab

X axis label.

ylab

Y axis label.

fill_col

Fill colours for histograms. A named vector with names "F" and "M" for female and male.

line_col

Line colours for histograms. A named vector with names "F" and "M" for female and male.

survey_cols

An optional named character vector of colors for the various surveys.

alpha

Transparency for the fill color in the histograms.

bin_size

Bin size. Should match the bin size used with the ⁠tidy_*()⁠ function.

min_total

Minimum number of fish for a given survey and year needed before a histogram is shown.

show_year

Which years to show a label for. Can be one of 'even' or 'odd'. Any other value will enable labels for all years.

french

French

Details

  • tidy_lengths_raw() or tidy_lengths_weighted() prepares PBS data for plot_lengths(). Works across one or multiple species.

  • plot_lengths() Plots length frequencies for each year for selected surveys for a single species.

Examples

## Not run: 
# # main age/length data:
# rs_comm_samples <- gfdata::get_commercial_samples("redstripe rockfish")
# rs_survey_samples <- gfdata::get_survey_samples("redstripe rockfish")
#
# # for weighting:
# rs_catch <- gfdata::get_catch("redstripe rockfish")
# rs_survey_sets <- gfdata::get_survey_sets("redstripe rockfish")

# survey raw length frequencies:
tidy_lengths_raw(rs_survey_samples,
  sample_type = "survey",
  bin_size = 2) %>%
  plot_lengths()

# survey weighted length frequencies:
tidy_lengths_weighted(rs_survey_samples,
  sample_type = "survey",
  bin_size = 2,
  dat_survey_sets = rs_survey_sets) %>%
  plot_lengths()

# commercial raw length frequencies:
tidy_lengths_raw(rs_comm_samples,
  sample_type = "commercial",
  bin_size = 2) %>%
  plot_lengths()

## End(Not run)

seananderson/gfplot documentation built on April 5, 2024, 6:29 a.m.