plot_CatL()
View source ↗On this page
Compare the observed and fitted survey indices, either over time for each length bin or across lengths for each time step.
Usage
plot_CatL(
model_result,
point_size = NULL,
point_color = NULL,
point_shape = 16,
line_size = NULL,
line_color = NULL,
line_type = "solid",
line_size1 = NULL,
line_color1 = NULL,
line_type1 = "solid",
line_alpha1 = 1,
line_size2 = NULL,
line_color2 = NULL,
line_type2 = "solid",
line_alpha2 = 0.6,
facet_ncol = NULL,
facet_scales = "free",
facet_by = c("length", "year"),
exp_transform = FALSE,
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
| Argument | Default | Description |
|---|---|---|
model_result | required | A fit that contains |
point_size | NULL | Numeric or NULL. Size of the observed points with |
point_color | NULL | Character or NULL. Color of the observed points with |
point_shape | 16 | Numeric. Shape of the observed points, such as 1 (open circle), 15 (square), 16 (filled circle, default) or 17 (triangle). |
line_size | NULL | Numeric or NULL. Width of the fitted line with |
line_color | NULL | Character or NULL. Color of the fitted line with |
line_type | "solid" | Character. Line type of the fitted line with |
line_size1 | NULL | Numeric or NULL. Width of the fitted line with |
line_color1 | NULL | Character or NULL. Color of the fitted line with |
line_type1 | "solid" | Character. Line type of the fitted line with |
line_alpha1 | 1 | Numeric. Transparency of the fitted line with |
line_size2 | NULL | Numeric or NULL. Width of the observed line with |
line_color2 | NULL | Character or NULL. Color of the observed line and of isolated observations with |
line_type2 | "solid" | Character. Line type of the observed line with |
line_alpha2 | 0.6 | Numeric. Transparency of the observed line and of isolated observations with |
facet_ncol | NULL | Integer or NULL. Number of columns of panels. NULL chooses it from the number of panels, for example 5 × 3 for 15 panels and 6 × 4 for 23. |
facet_scales | "free" | Character. Axis scales of the panels, "fixed", "free", "free_x" or "free_y". Letter case does not matter. |
facet_by | c("length", "year") | Character. "length" (default) draws one panel per length bin with time on the x axis; "year" draws one panel per time step with length on the x axis. Letter case does not matter. |
exp_transform | FALSE | Logical. TRUE exponentiates the logged observations and fitted values to the original survey-index scale, where the fitted curves are conditional medians. FALSE keeps the log scale. |
return_data | FALSE | Logical. TRUE returns a list with the plot, the fitted values and the observations (see Value). Default FALSE. |
title | NULL | NULL (default) draws the default title, FALSE, NA or "" draws no title, and a character string draws that string; see |
xlab | NULL | Character or NULL. Label of the x axis. NULL uses the global theme setting. |
ylab | NULL | Character or NULL. Label of the y axis, used as given. NULL uses Survey index on the original scale and Log survey index on the natural-log scale; a global survey label replaces Survey index and takes the prefix Log on the log scale. |
font_family | NULL | Character or NULL. Font family of the text, which must be installed on the computer. NULL uses the global theme setting (default "sans"). |
title_size | NULL | Numeric or NULL. Size of the plot title in pt. NULL uses the global theme setting (default 14). |
axis_title_size | NULL | Numeric or NULL. Size of the axis titles in pt. NULL uses the global theme setting (default 12). |
axis_text_size | NULL | Numeric or NULL. Size of the axis tick labels in pt. NULL uses the global theme setting (default 10). |
strip_text_size | NULL | Numeric or NULL. Size of the panel labels in pt. NULL uses the global theme setting (default 10). |
legend_text_size | NULL | Numeric or NULL. Size of the legend text in pt. NULL uses the global theme setting (default 10). |
x_breaks | NULL | 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_theme | NULL | 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_hjust | NULL | 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. |
... | … | The former argument name type (for facet_by), accepted with a warning. |
Value
A ggplot object, or with return_data = TRUE a list with plot, the fitted values data1 and the observations data2.
Details
With facet_by = "length" (default) each length bin has a panel with time on the x axis; the observations are points and the fitted values a line. With facet_by = "year" each time step has a panel with length on the x axis, and both are lines. line_size1 sets the width of the fitted line and line_size2 that of the observed line. Gaps split the observed line, and an isolated observation is drawn as a point sized by point_size. A legend below the panels names the observed and the fitted series.
Line widths that come from the theme default are thinner in plots with many panels, at full width up to 4 panels, two thirds for 5 to 12 panels and half beyond. With 20 panels, for example, the defaults of line_size1 and line_size2 are 0.6 and 0.33. A width given in the call, or a global line_size other than the value of the style, is kept.
The default exp_transform = FALSE draws natural-log survey indices and says so in the y-axis label. exp_transform = TRUE draws the survey indices on their original scale, where the fitted curves are conditional medians, not bias-corrected means. A ylab given in the call replaces the automatic label.
The observed and predicted matrices are aligned by position with the fitted time and length metadata; their row and column names do not change the coordinates. Missing and zero observations leave gaps. Dimensions and metadata must agree, and the predictions must be finite, also after the exponential transformation; use exp_transform = FALSE when exponentiating would overflow.
The y axis shows survey indices, not fishery catch. acl_theme_set(ylab = list(survey = "Survey index (per tow)")) labels the single-model and the comparison survey plots together, with the prefix Log on the log scale. When survey is not set, a custom global abundance label is used; when neither is set, the label is Survey index. The catch label is used only by the catch plots.
Additional details from R help
The predicted and observed matrices are matched by position to the time steps and length bins of the fit; their row and column names are not used. Missing and zero observations leave gaps. An isolated observation is drawn as a point. A legend below the panels names the observed and the fitted series, with the widths and transparencies of their lines. Dimensions and metadata must agree; predictions must be finite, including after an exponential transformation.
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_CatL(b, facet_by = "length", exp_transform = FALSE,
point_size = 1, line_size = 0.6,
ylab = "Log survey index")

plot_CatL(b, facet_by = "year")