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)
dat | A data frame from |
---|---|
xlab | X axis label. |
ylab | Y axis label. |
fill_col | Fill colours for histograms. A named vector with names
|
line_col | Line colours for histograms. A named vector with names
|
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 |
min_total | Minimum number of fish for a given survey and year needed before a histogram is shown. |
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.
# 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() # }