On this page

Plot spawning stock biomass (SSB) against the recruitment it produced, from a fitted model.

Usage

plot_SSB_Rec(
  model_result,
  age_at_recruitment = NULL,
  point_size = NULL,
  point_color = NULL,
  point_shape = 16,
  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
model_resultrequired

A fit from run_acl() or run_alscl(); its report must contain SSB and Rec.

age_at_recruitmentNULL

Numeric or NULL. Recruitment age in years, used to pair SSB with later recruitment. NULL (default) uses the youngest fitted age model_result$age[1], which is 1 year for an annual fit with rec.age = 1 and one quarter for a quarterly fit with rec.age = 0.25; a fit without age metadata uses 1 year. A supplied value must be nonnegative and an exact multiple of the growth_step of the model; 0 pairs SSB and recruitment in the same time step.

point_sizeNULL

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

point_colorNULL

Character or NULL. Color of the points. NULL inherits the global point_color setting.

point_shape16

Numeric. Shape of the points, as in ?points of base R. Default 16 (filled circle).

return_dataFALSE

Logical. TRUE returns a list with the plot and the paired values (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 and data, the paired values of SSB and recruitment (columns SSB and Rec).

Details

The points are fitted quantities; the plot fits no stock-recruitment relationship.

Recruitment in a time step is the number of fish at the youngest fitted age, so each SSB value is paired with the recruitment age_at_recruitment years later. The default NULL uses the youngest fitted age; if that age is not a whole number of time steps, the nearest whole number of steps is used and a message says so. A supplied value is divided by the growth_step of the fit and must give a whole number of time steps on a regular time grid. With quarterly data, 0.25 means a lag of one time step and 1 a lag of four. A lag of zero is allowed; negative, nonfinite and fractional lags are errors. A fit without growth_step uses the spacing of its time steps, and one year when it has no time metadata.

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_SSB_Rec(b, age_at_recruitment = 1)
Example figure
Example figure: plot_SSB_Rec(b, age_at_recruitment = 1)

See also

Search documentation