Functions for plotting length frequency data.

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, bin_size = 2, min_total = 20)

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.

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 <- get_commercial_samples("redstripe rockfish")
# rs_survey_samples <- get_survey_samples("redstripe rockfish")
#
# # for weighting:
# rs_catch <- get_catch("redstripe rockfish")
# rs_survey_sets <- 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()
# }