On this page

Plot the model catch in numbers or in weight divided by its mean, with an optional reported catch series scaled in the same way.

Usage

plot_relative_catch(
  fit,
  observed = NULL,
  type = c("number", "weight"),
  years = NULL,
  line_size = NULL,
  line_color = NULL,
  line_type = "solid",
  point_size = NULL,
  observed_color = NULL,
  observed_name = "Reported catch",
  return_data = FALSE,
  title = NULL,
  xlab = NULL,
  ylab = NULL,
  font_family = NULL,
  title_size = NULL,
  axis_title_size = NULL,
  axis_text_size = NULL,
  strip_text_size = NULL,
  legend_text_size = NULL,
  x_breaks = NULL,
  base_theme = NULL,
  title_hjust = NULL
)

Arguments

ArgumentDefaultDescription
fitrequired

An ACL or ALSCL fit, or a saved fit read with read_assessment().

observedNULL

NULL or a data frame of reported catch, drawn as points. It needs the columns year (the time step, as in fit$year) and catch (reported catch in numbers or in weight, to match type, in any unit). Rows of time steps that are not in the fit and rows with a missing catch are not drawn.

typec("number", "weight")

Character. "number" (default) for catch in numbers, "weight" for catch in weight. Letter case does not matter.

yearsNULL

NULL or the time steps over which the mean is calculated, as values of fit$year. NULL uses all time steps of the fit, or, with observed, the time steps of the fit that have a reported catch. With observed, time steps without a reported catch are left out of years.

line_sizeNULL

Numeric or NULL. Line width. NULL inherits the global line_size setting.

line_colorNULL

Character or NULL. Color of the fitted series. NULL inherits the global catch_color setting, or line_color when that is NULL.

line_type"solid"

Character. Line type, such as "solid" or "dashed". Default "solid".

point_sizeNULL

Numeric or NULL. Size of the points of observed; NULL inherits the global point_size setting (default 2.5).

observed_colorNULL

Character or NULL. Color of the points of observed; NULL inherits the global observed_color setting.

observed_name"Reported catch"

Character. Name of the reported series in the legend. Default "Reported catch".

return_dataFALSE

Logical. TRUE returns a list with the plot and the plotted data (see Value). Default FALSE.

titleNULL

NULL (default) draws the default title, FALSE, NA or "" draws no title, and a character string draws that string; see acl_theme_set() for the default titles and the show_title setting.

xlabNULL

Character or NULL. Label of the x axis. NULL uses the global theme setting.

ylabNULL

Character or NULL. Label of the y axis. NULL uses the global theme setting.

font_familyNULL

Character or NULL. Font family of the text, which must be installed on the computer. NULL uses the global theme setting (default "sans").

title_sizeNULL

Numeric or NULL. Size of the plot title in pt. NULL uses the global theme setting (default 14).

axis_title_sizeNULL

Numeric or NULL. Size of the axis titles in pt. NULL uses the global theme setting (default 12).

axis_text_sizeNULL

Numeric or NULL. Size of the axis tick labels in pt. NULL uses the global theme setting (default 10).

strip_text_sizeNULL

Numeric or NULL. Size of the panel labels in pt. NULL uses the global theme setting (default 10).

legend_text_sizeNULL

Numeric or NULL. Size of the legend text in pt. NULL uses the global theme setting (default 10).

x_breaksNULL

Numeric vector or NULL. Positions of the x-axis breaks. NULL inherits the global x_breaks setting when at least one of its values lies on this axis; otherwise the breaks are chosen automatically.

base_themeNULL

Character or NULL. Name of the base ggplot2 theme, such as "bw", "minimal" or "theme_bw". NULL uses the global theme setting. Letter case does not matter.

title_hjustNULL

Numeric or NULL. Horizontal position of the title, 0 for left, 0.5 for centered and 1 for right. NULL uses the global theme setting.

Value

A ggplot object, or with return_data = TRUE a list with plot, data and observed. data is the model series with the columns Year, relative and extrapolated; observed is the reported series with the columns Year and relative, or NULL without a reported series.

Details

ACL and ALSCL are fitted to a survey index alone. Such a fit has no information on the absolute level of catch or of the fishing mortality rate, which depend on the assumed natural mortality rate and the assumed survey catchability (see relative_catch()). Only the trend should be compared. Both series are therefore divided by their mean over the same time steps, the y-axis label states that the values are relative, the subtitle gives the time steps of the mean, and a dotted horizontal line marks the value 1. No observation informs the fishing mortality rate in the terminal time step, so the model catch in that time step is a prediction; return_data = TRUE marks it in the column extrapolated. For an ACL fit with neither a live TMB object nor the stored inputs and settings, catch in weight is unavailable and type = "weight" is an error. The title uses the theme key relative_catch; the axis labels use xlab$year and ylab$relative_catch_number or ylab$relative_catch_weight.

Additional details from R help

ACL and ALSCL are fitted to a survey index alone. Such a fit has no information on the absolute level of catch or of the fishing mortality rate, which depend on the assumed natural mortality rate and the assumed survey catchability (see relative_catch()). Only the trend of the model catch should be compared with reported catch. Both series are therefore divided by their mean over the same time steps, and the y-axis label states that the values are relative. The subtitle gives the time steps of the mean. A dotted horizontal line marks the value 1, the mean of each series over those time steps.

No observation informs the fishing mortality rate in the last time step, so the model catch in that time step is a prediction; return_data = TRUE marks it in the column extrapolated.

For an ACL result with neither a live TMB object nor a stored recipe, catch in weight is unavailable and type = "weight" is an error.

The title uses the theme key relative_catch; the axis labels use xlab$year and ylab$relative_catch_number or ylab$relative_catch_weight.

Examples

Run the setup before the example. Fitting examples require an R-compatible C++ toolchain; simulation and export examples may write files.

Example setup
library(ALSCL)
library(ggplot2)
library(patchwork)
data("YTF_example")
x <- YTF_example
inputs <- x[c("data.CatL", "data.wgt", "data.mat")]
dat <- x$data.CatL
a <- run_acl(x, silent = TRUE)
b <- run_alscl(x, silent = TRUE)
# Use objects defined above
plot_relative_catch(b)
# Compare the trend with the catch in weight of the data-generating simulation; use reported catch in practice
simulated <- data.frame(year = b$year, catch = x$truth$CB)
plot_relative_catch(b, observed = simulated, type = "weight", observed_name = "Simulated catch")
Example figure
Example figure: plot_relative_catch(b, observed = simulated, type = "weight", observed_name = "Simulated catch")

See also

Search documentation