Functions for plotting age frequency data.
plot_ages(dat, max_size = 5, sex_gap = 0.2, year_increment = 2, ylab = "Age (years)", year_range = NULL, line_col = c(M = "#666666", F = "#f44256"), survey_cols = NULL, alpha = 0.2, grid_col = "grey95", diagonal_lines = seq(-2100, -1850, 10), count_label_size = 2.25)
| dat | Input data frame. Should be from |
|---|---|
| max_size | Maximum dot size (passed to |
| sex_gap | Horizontal gap between male and female bubbles. |
| year_increment | Increment between year labels on x axis. |
| ylab | Y axis label. |
| year_range | If not |
| line_col | A named character vector of colors for male and females. |
| survey_cols | If not |
| alpha | Transparency for the fill color. |
| grid_col | Colour for the gridlines. |
| diagonal_lines | A numeric a vector of years to start diagonal lines at
to help trace cohorts. Note that these are passed to
|
| count_label_size | The size of the total count labels along the top.
Passed to |
tidy_ages_raw() or tidy_ages_weighted() prepare PBS data for plot_ages().
These work across one or multiple species.
plot_ages() Plots age frequencies for each year for selected surveys for
a single species. Input data frame should come from tidy_ages_raw() or
tidy_ages_weighted() or follow the following format: The input data frame
must have the columns (in any order): survey, year, sex (coded as "M"
and "F"), age, proportion, total (for the total sample number label).
# NOT RUN { pop_samples %>% tidy_ages_raw(survey = "SYN QCS") %>% plot_ages() # 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 age frequencies: tidy_ages_raw(rs_survey_samples, sample_type = "survey") %>% plot_ages() # survey weighted age frequencies: tidy_ages_weighted(rs_survey_samples, sample_type = "survey", dat_survey_sets = rs_survey_sets) %>% plot_ages() # commercial raw age frequencies: tidy_ages_raw(rs_comm_samples, sample_type = "commercial") %>% plot_ages() # }