| Title: | Plot gadget3 models |
|---|---|
| Description: | Creates plots of gadget.fit objects for gadget3 (Globally applicable Area Disaggregated General Ecosystem Toolbox) stock assessment model framework. |
| Authors: | Mikko Vihtakari [aut, cre] (affiliation: Institute of Marine Research, ORCID: <https://orcid.org/0000-0003-0371-4319>), Bjarki Thor Elvarsson [aut], Will Butler [aut], Jamie Lentin [aut], Marine and Freshwater Research Institute (Iceland) [cph], Institute of Marine Research (Norway) [cph] |
| Maintainer: | Mikko Vihtakari <[email protected]> |
| License: | GPL-3 |
| Version: | 0.3.11 |
| Built: | 2026-12-02 09:24:44 UTC |
| Source: | https://github.com/gadget-framework/gadgetplots |
Age-length input data to gadget
aldist_examplealdist_example
Data frame with gadget attributes containing Greenland halibut age-length distributions from the Institute of Marine Research EggaNord survey.
Joint Russian-Norwegian Arctic Fisheries Working Group
Other datasets:
example_catches,
fit,
ldist_example,
sexratio_example,
stockdist_example
The dplot functions plot data passed to a gadget3 model instead of data from the model or fit objects.
dplot_adist( x, type = "bar", color_palette = scales::brewer_pal(palette = "Set1"), dir = "v", base_size = 8, ... )dplot_adist( x, type = "bar", color_palette = scales::brewer_pal(palette = "Set1"), dir = "v", base_size = 8, ... )
x |
A gadget3 ready data frame created using mfdb, g3_data or add_g3_attributes. |
type |
Character specifying the plot type: "bar" or "ggridges". |
color_palette |
A function defining the color palette to be used for fill of bars. |
dir |
Character specifying the direction of the facets ("h" for horizontal, "v" for vertical). See |
base_size |
Base size parameter for ggplot. See ggtheme. |
... |
Additional arguments passed to |
A ggplot object.
data(aldist_example) dplot_adist(aldist_example) dplot_adist(aldist_example, type = "ggridges")data(aldist_example) dplot_adist(aldist_example) dplot_adist(aldist_example, type = "ggridges")
The dplot functions plot data passed to a gadget3 model instead of data from the model or fit objects.
dplot_aldist( x, type = "bar", facet_age = FALSE, dir = "v", color_palette = scales::brewer_pal(palette = "Set1"), base_size = 8, ... )dplot_aldist( x, type = "bar", facet_age = FALSE, dir = "v", color_palette = scales::brewer_pal(palette = "Set1"), base_size = 8, ... )
x |
A gadget3 ready data frame created using mfdb, g3_data or add_g3_attributes. |
type |
Character specifying the plot type: "bar", "step", or "area". "step" produces a similar plot where age and length distributions are plotted separately as in plot_catchdist. "area" produces an area plot instead of a bar plot, but works poorly when there are many age groups. |
facet_age |
Logical indicating whether ages should be plotted in separate facets. Does not apply for |
dir |
Character specifying the direction of the facets ("h" for horizontal, "v" for vertical). See |
color_palette |
A function defining the color palette to be used for fill of bars when |
base_size |
Base size parameter for ggplot. See ggtheme. |
... |
Additional arguments passed to |
A ggplot object.
data(aldist_example) dplot_aldist(aldist_example) dplot_aldist(aldist_example, type = "step") # as in plot_catchdist dplot_aldist(aldist_example, facet_age = TRUE) dplot_aldist(aldist_example, type = "area") # works poorlydata(aldist_example) dplot_aldist(aldist_example) dplot_aldist(aldist_example, type = "step") # as in plot_catchdist dplot_aldist(aldist_example, facet_age = TRUE) dplot_aldist(aldist_example, type = "area") # works poorly
The dplot functions plot data passed to a gadget3 model instead of data from the model or fit objects.
dplot_catch(x, base_size = 8)dplot_catch(x, base_size = 8)
x |
A gadget3 ready data frame created using mfdb, g3_data or add_g3_attributes. Can be a single data frame or a named list of data frames in which case multiple catches are plotted in the same figure. |
base_size |
Base size parameter for ggplot. See ggtheme. |
A ggplot object.
data(example_catches) dplot_catch(TrawlNor_catches) dplot_catch( list("TrawlNor" = TrawlNor_catches, "OtherNor" = OtherNor_catches, "TrawlRus" = TrawlRus_catches, "OtherRus" = OtherRus_catches, "Internat" = Internat_catches) )data(example_catches) dplot_catch(TrawlNor_catches) dplot_catch( list("TrawlNor" = TrawlNor_catches, "OtherNor" = OtherNor_catches, "TrawlRus" = TrawlRus_catches, "OtherRus" = OtherRus_catches, "Internat" = Internat_catches) )
The dplot functions plot data passed to a gadget3 model instead of data from the model or fit objects.
dplot_ldist(x, type = "bar", scales = "free_y", dir = "v", base_size = 8, ...)dplot_ldist(x, type = "bar", scales = "free_y", dir = "v", base_size = 8, ...)
x |
A gadget3 ready data frame created using mfdb, g3_data or add_g3_attributes. |
type |
Character specifying the plot type: "bar", "ggridges" or "line" |
scales |
Character specifying the |
dir |
Character specifying the direction of the facets ("h" for horizontal, "v" for vertical). See |
base_size |
Base size parameter for ggplot. See ggtheme. |
... |
Additional arguments passed to |
A ggplot object.
data(ldist_example) dplot_ldist(ldist_example) dplot_ldist(ldist_example, type = "ggridges") dplot_ldist(ldist_example, type = "line")data(ldist_example) dplot_ldist(ldist_example) dplot_ldist(ldist_example, type = "ggridges") dplot_ldist(ldist_example, type = "line")
The dplot functions plot data passed to a gadget3 model instead of data from the model or fit objects.
dplot_sexr(x, dir = "v", base_size = 8, ...)dplot_sexr(x, dir = "v", base_size = 8, ...)
x |
A gadget3 ready data frame created using mfdb, g3_data or add_g3_attributes. |
dir |
Character specifying the direction of the facets ("h" for horizontal, "v" for vertical). See |
base_size |
Base size parameter for ggplot. See ggtheme. |
... |
Additional arguments passed to |
A ggplot object.
data(sexratio_example) dplot_sexr(sexratio_example)data(sexratio_example) dplot_sexr(sexratio_example)
The dplot functions plot data passed to a gadget3 model instead of data from the model or fit objects.
dplot_stockdist( x, stock_col = "maturity_stage", proportion = FALSE, group_by_sex = FALSE, sexes = c(female = "^female", male = "^male"), colors = NULL, scales = "free_y", dir = "v", base_size = 8, ... )dplot_stockdist( x, stock_col = "maturity_stage", proportion = FALSE, group_by_sex = FALSE, sexes = c(female = "^female", male = "^male"), colors = NULL, scales = "free_y", dir = "v", base_size = 8, ... )
x |
A gadget3 ready data frame created using mfdb, g3_data or add_g3_attributes. |
stock_col |
Character defining the name of the column separating stocks. |
proportion |
Logical indicating whether to plot proportion of stocks instead of absolute numbers. |
group_by_sex |
Logical indicating whether to take the proportions by sex ( |
sexes |
Named vector of length two containing regular expressions separating
sexes in |
colors |
A vector of colors to be used for stocks. If |
scales |
Character specifying the |
dir |
Character specifying the direction of the facets ("h" for horizontal, "v" for vertical). See |
base_size |
Base size parameter for ggplot. See ggtheme. |
... |
Additional arguments passed to |
A ggplot object.
data(stockdist_example) dplot_stockdist(stockdist_example) dplot_stockdist(stockdist_example, proportion = TRUE) dplot_stockdist(stockdist_example, proportion = TRUE, group_by_sex = TRUE)data(stockdist_example) dplot_stockdist(stockdist_example) dplot_stockdist(stockdist_example, proportion = TRUE) dplot_stockdist(stockdist_example, proportion = TRUE, group_by_sex = TRUE)
Catch input data to gadget
TrawlNor_catches Internat_catches OtherNor_catches Internat_catches OtherRus_catches TrawlRus_catches TrawlNor_catchesTrawlNor_catches Internat_catches OtherNor_catches Internat_catches OtherRus_catches TrawlRus_catches TrawlNor_catches
Data frame with gadget attributes containing Greenland halibut catches for ICES areas 1 and 2 (Northeast Arctic)
An object of class data.frame with 43 rows and 4 columns.
An object of class data.frame with 43 rows and 4 columns.
An object of class data.frame with 43 rows and 4 columns.
An object of class data.frame with 43 rows and 4 columns.
An object of class data.frame with 43 rows and 4 columns.
An object of class data.frame with 43 rows and 4 columns.
Joint Russian-Norwegian Arctic Fisheries Working Group
Other datasets:
aldist_example,
fit,
ldist_example,
sexratio_example,
stockdist_example
An example gadget.fit object.
fitfit
gadget.fit object containing an early draft of the gadget model for Northeast Arctic Greenland halibut stock assessment. This draft is used because the final model is too large as an example dataset.
Joint Russian-Norwegian Arctic Fisheries Working Group
Other datasets:
aldist_example,
example_catches,
ldist_example,
sexratio_example,
stockdist_example
Plot all observational data from a gadget model
g3d_plot(model, regexp = NULL, scales = "fixed", ncol = NULL, base_size = 8)g3d_plot(model, regexp = NULL, scales = "fixed", ncol = NULL, base_size = 8)
model |
R or TMB model. A model object from g3_to_r or g3_to_tmb functions. |
regexp |
Either |
scales |
Character defining the |
ncol |
Number of columns passed to |
base_size |
Base size parameter for ggplot. See ggtheme. |
Plots data as contained in a gadget model. Helpful in checking models for possible data issues and for documentation of models.
A list of ggplot objects.
Plot Andersen suitability using model parameters
g3plot_andersen( length, p0, p1, p2, p3, p4, p5, add = FALSE, base_size = 8, ... )g3plot_andersen( length, p0, p1, p2, p3, p4, p5, add = FALSE, base_size = 8, ... )
length |
Numeric vector defining the lengths for which suitabilities should be plotted |
p0, p1, p2, p3, p4, p5
|
(Named) numeric vectors defining the Andersen suitability function parameters. See suitability. If length > 1, multiple curves will be plotted using a different line type. All of these parameters must have the same length. |
add |
Logical indicating whether the function should produce a ggplot2 layer which can be added to an existing ggplot ( |
base_size |
Base size parameter for ggplot. See ggtheme. |
... |
Additional arguments passed to |
g3plot_andersen(length = 1:120, p0 = 0, p1 = 0.659, p2 = 1, p3 = 0.15, p4 = 1e4, p5 = 120)g3plot_andersen(length = 1:120, p0 = 0, p1 = 0.659, p2 = 1, p3 = 0.15, p4 = 1e4, p5 = 120)
Plot exponentiall50 suitability using model parameters
g3plot_exponentiall50(length, alpha, l50, add = FALSE, base_size = 8, ...)g3plot_exponentiall50(length, alpha, l50, add = FALSE, base_size = 8, ...)
length |
Numeric vector defining the lengths for which suitabilities should be plotted |
alpha |
(Named) numeric vector defining the exponentiall50 slopes. If length > 1, multiple curves will be plotted using a different line type. See suitability. |
l50 |
Numeric vector defining the exponentiall50 l50 values. Must be same length than |
add |
Logical indicating whether the function should produce a ggplot2 layer which can be added to an existing ggplot ( |
base_size |
Base size parameter for ggplot. See ggtheme. |
... |
Additional arguments passed to |
data(fit) suit <- fit$params[grepl("ghl_female.ecos.survey", fit$params$switch),] g3plot_exponentiall50( length = 1:60, alpha = unlist(suit[grepl("alpha", suit$switch), "value"]), l50 = unlist(suit[grepl("l50", suit$switch), "value"]) )data(fit) suit <- fit$params[grepl("ghl_female.ecos.survey", fit$params$switch),] g3plot_exponentiall50( length = 1:60, alpha = unlist(suit[grepl("alpha", suit$switch), "value"]), l50 = unlist(suit[grepl("l50", suit$switch), "value"]) )
Wrapper for plot.gadget.fit that saves all diagnostic graphs to a directory
gadget_plots( fit, path, file_type = "png", quiet = FALSE, width = NULL, height = NULL, units = "cm", res = 300, ... )gadget_plots( fit, path, file_type = "png", quiet = FALSE, width = NULL, height = NULL, units = "cm", res = 300, ... )
fit |
A gadget fit object. See |
path |
Directory path for saving figures. |
file_type |
Character. Either one of the |
quiet |
Logical indicating whether to print messages about the plotting process. Set to |
width, height
|
Plot size given in |
units |
Units for plot size. See |
res |
Plot resolution. See the |
... |
Additional arguments to plotting functions (only used for plot_annual at the moment) |
Returns nothing, but makes the requested files.
make_html
Length input data to gadget
ldist_exampleldist_example
Data frame with gadget attributes containing Greenland halibut length distributions from the Institute of Marine Research EggaNord survey.
Joint Russian-Norwegian Arctic Fisheries Working Group
Other datasets:
aldist_example,
example_catches,
fit,
sexratio_example,
stockdist_example
Save diagnostic graphs to a single html document
make_html( fit, path = getwd(), harvest_rate = TRUE, file_name = "model_output_figures.html", template = "standard", model_name = "Gadget model output" )make_html( fit, path = getwd(), harvest_rate = TRUE, file_name = "model_output_figures.html", template = "standard", model_name = "Gadget model output" )
fit |
A gadget fit object. See |
path |
Directory path for saving the html output. Defaults to working directory. |
harvest_rate |
A Logical value, if |
file_name |
Character specifying the name of the html file without path. Must include the file extension. |
template |
Character specifying the html template to use. See details. |
model_name |
Character specifying the name of the model when "standard |
The package contains html templates tailored for different stocks needed by the authors. Specify the name in the template argument. Current alternatives are:
Standard model output figures. Use the harvest_rate argument to switch between F and HR figures.
Output tailored for Icelandic stock assessment.
Output tailored for Northeast Arctic Greenland halibut assessment.
Returns nothing, but makes the requested file. See the webpage for example output.
Plot model age distributions for stocks by year
plot_adist( fit, type = "bar", scales = "fixed", ncol = NULL, years = NULL, base_size = 8 )plot_adist( fit, type = "bar", scales = "fixed", ncol = NULL, years = NULL, base_size = 8 )
fit |
A gadget fit object. See |
type |
Character specifying the plot type. Options: |
scales |
Character defining the |
ncol |
Number of columns passed to |
years |
Numeric vector defining which years to plot. If |
base_size |
Base size parameter for ggplot. See ggtheme. |
A ggplot object or a list of such objects depending on the type argument.
data(fit) plot_adist(fit) plot_adist(fit, type = "line") plot_adist(fit, type = "ggridges")data(fit) plot_adist(fit) plot_adist(fit, type = "line") plot_adist(fit, type = "ggridges")
Plot an age class from the model
Plots age class from the model at the beginning of the year
plot_ageclass( fit, age = 2, biomass = FALSE, base_size = 8, return_data = FALSE )plot_ageclass( fit, age = 2, biomass = FALSE, base_size = 8, return_data = FALSE )
fit |
A gadget fit object. See |
age |
Integer specifying the age class to plot. |
biomass |
Logical indicating whether biomass should be plotted instead of abundance. |
base_size |
Base size parameter for ggplot. See ggtheme. |
return_data |
Logical indicating whether to return data for the plot instead of the plot itself. |
A ggplot object.
data(fit) plot_ageclass(fit) plot_ageclass(fit, age = 5, biomass = TRUE)data(fit) plot_ageclass(fit) plot_ageclass(fit, age = 5, biomass = TRUE)
Plot of age composition from the model
plot_agecomp( fit, type = "bubble", scales = "fixed", biomass = FALSE, base_size = 8, return_data = FALSE )plot_agecomp( fit, type = "bubble", scales = "fixed", biomass = FALSE, base_size = 8, return_data = FALSE )
fit |
A gadget fit object. See |
type |
Character specifying the plot type. Options: |
scales |
Character defining the |
biomass |
Logical indicating whether biomass should be plotted instead of abundance. |
base_size |
Base size parameter for ggplot. See ggtheme. |
return_data |
Logical indicating whether to return data for the plot instead of the plot itself. |
Possible plot types are:
Facetted bar plot with year on x-axis, abundance on y-axis and ages along rows. Year classes are colored.
Facetted line plot with year on x-axis, abundance on y-axis and ages along rows. Stocks are colored.
Same as above but the bars are overlapping.
Bubble plot with year on x-axis, age on y-axis and point size scaled to abundance. Year classes are colored.
Note that both "bar" and "bubble" contain extra information as text for plotly::ggplotly.
A ggplot object.
data(fit) plot_agecomp(fit) plot_agecomp(fit, type = "line", biomass = TRUE) plot_agecomp(fit, type = "bar") plot_agecomp(fit, type = "ggridges")data(fit) plot_agecomp(fit) plot_agecomp(fit, type = "line", biomass = TRUE) plot_agecomp(fit, type = "bar") plot_agecomp(fit, type = "ggridges")
Plot of fitted growth for each age-length component
plot_agelength(fit, name = NULL, base_size = 8)plot_agelength(fit, name = NULL, base_size = 8)
fit |
A gadget fit object. See |
name |
A character vector specifying the unique(fit$catchdist.fleets$name) to plot. If |
base_size |
Base size parameter for ggplot. See ggtheme. |
A ggplot object. A list of ggplot objects if there are multiple age-length (aldist) data sources (unique(fit$catchdist.fleets$name)).
data(fit) plot_agelength(fit)data(fit) plot_agelength(fit)
Plot annual ICES type of graphic returning central model data
plot_annual( fit, harvest_rate = TRUE, color_palette = scales::hue_pal(), base_size = 8, ... )plot_annual( fit, harvest_rate = TRUE, color_palette = scales::hue_pal(), base_size = 8, ... )
fit |
A gadget fit object. See |
harvest_rate |
A Logical value, if |
color_palette |
A function defining the color palette to be used or a vector of colors which is 1 longer than the number of stocks in the model. The extra color will be used for total estimate. See scale_color_manual. |
base_size |
Base size parameter for ggplot. See ggtheme. |
... |
Additional arguments passed to |
A ggplot object. If fleet = NULL, a list of ggplot objects.
data(fit) # Annual plot with custom colors plot_annual(fit, color_palette = scales::brewer_pal(palette = "Spectral"))data(fit) # Annual plot with custom colors plot_annual(fit, color_palette = scales::brewer_pal(palette = "Spectral"))
Plot stock biomasses
plot_biomass( fit, type = "line", total = FALSE, biomass = TRUE, stocks = NULL, min_catch_length = NULL, return_data = FALSE, base_size = 8, scale = c("kt", "Mt", "t") )plot_biomass( fit, type = "line", total = FALSE, biomass = TRUE, stocks = NULL, min_catch_length = NULL, return_data = FALSE, base_size = 8, scale = c("kt", "Mt", "t") )
fit |
A gadget fit object. See |
type |
Character specifying the plot type. Options: "line" or "area". See examples. |
total |
Logical indicating whether total biomass should be plotted. Has no effect if |
biomass |
Logical indicating whether biomass should be plotted instead of abundance. |
stocks |
Character specifying the substock to plot in |
min_catch_length |
Numeric value defining the minimum catch length (size), which will be used to filter ( |
return_data |
Logical indicating whether to return data for the plot instead of the plot itself. |
base_size |
Base size parameter for ggplot. See ggtheme. |
scale |
Character specifying the display unit of biomass: |
A ggplot object.
data(fit) plot_biomass(fit) plot_biomass(fit, biomass = FALSE, total = TRUE) plot_biomass(fit, type = "area") plot_biomass(fit, min_catch_length = 45)data(fit) plot_biomass(fit) plot_biomass(fit, biomass = FALSE, total = TRUE) plot_biomass(fit, type = "area") plot_biomass(fit, min_catch_length = 45)
Plot catches
plot_catch( fit, type = "stock", biomass = TRUE, base_size = 8, return_data = FALSE, scale = c("kt", "Mt", "t") )plot_catch( fit, type = "stock", biomass = TRUE, base_size = 8, return_data = FALSE, scale = c("kt", "Mt", "t") )
fit |
A gadget fit object. See |
type |
Character specifying the data type: |
biomass |
Logical indicating whether biomass should be plotted instead of estimated abundance. |
base_size |
Base size parameter for ggplot. See ggtheme. |
return_data |
Logical indicating whether to return data for the plot instead of the plot itself. |
scale |
Character specifying the display unit of catch in biomass: |
A ggplot object.
data(fit) plot_catch(fit) plot_catch(fit, biomass = FALSE) plot_catch(fit, type = "total") plot_catch(fit, type = "fleet") plot_catch(fit, type = "hr")data(fit) plot_catch(fit) plot_catch(fit, biomass = FALSE) plot_catch(fit, type = "total") plot_catch(fit, type = "fleet") plot_catch(fit, type = "hr")
Plots the length distribution of each fit$catchdist.fleets$name
plot_catchdist(fit, type = "step", name = NULL, base_size = 8)plot_catchdist(fit, type = "step", name = NULL, base_size = 8)
fit |
A gadget fit object. See |
type |
Character specifying the plot type: |
name |
A character vector specifying the unique(fit$catchdist.fleets$name) to plot. If |
base_size |
Base size parameter for ggplot. See ggtheme. |
A list of ggplot objects consisting of a separate plot for each of names.
data(fit) # Only one data set to save space: plot_catchdist(fit, name = "EggaN_ldist") plot_catchdist(fit, name = "EggaN_ldist", type = "line")data(fit) # Only one data set to save space: plot_catchdist(fit, name = "EggaN_ldist") plot_catchdist(fit, name = "EggaN_ldist", type = "line")
Plot fishing mortality
plot_f( fit, stocks = NULL, fbar_ages = NULL, return_data = FALSE, base_size = 8 )plot_f( fit, stocks = NULL, fbar_ages = NULL, return_data = FALSE, base_size = 8 )
fit |
A gadget fit object. See |
stocks |
Character specifying the substock to plot in |
fbar_ages |
Either |
return_data |
Logical indicating whether to return data for the plot instead of the plot itself. |
base_size |
Base size parameter for ggplot. See ggtheme. |
The function calculates either average fishing mortality per substock or average fishing mortality over an age range depending on the fbar_ages argument.
A ggplot object.
data(fit) plot_f(fit) plot_f(fit, fbar_ages = 5:10)data(fit) plot_f(fit) plot_f(fit, fbar_ages = 5:10)
Plot of average growth for each stock
plot_growth( fit, type = "annual", stdev = FALSE, add_models = FALSE, base_size = 8 )plot_growth( fit, type = "annual", stdev = FALSE, add_models = FALSE, base_size = 8 )
fit |
A gadget fit object. See |
type |
Character specifying the plot type. Options: |
stdev |
Logical indicating whether standard deviation should be shown on both sides of mean for plots that use mean lengths. |
add_models |
Logical indicating whether growth models extracted from growth parameters should be plotted together with the data. Uses grep and does not always work. |
base_size |
Base size parameter for ggplot. See ggtheme. |
A ggplot object.
data(fit) plot_growth(fit) plot_growth(fit, add_models = TRUE, stdev = TRUE) plot_growth(fit, type = "mean") plot_growth(fit, type = "stdev")data(fit) plot_growth(fit) plot_growth(fit, add_models = TRUE, stdev = TRUE) plot_growth(fit, type = "mean") plot_growth(fit, type = "stdev")
Plot harvest rate
plot_hr( fit, stocks = NULL, min_catch_length = NULL, biomass = TRUE, model_selectivity = TRUE, base_size = 8, return_data = FALSE )plot_hr( fit, stocks = NULL, min_catch_length = NULL, biomass = TRUE, model_selectivity = TRUE, base_size = 8, return_data = FALSE )
fit |
A gadget fit object. See |
stocks |
Character specifying the substock to plot in |
min_catch_length |
Numeric value defining the minimum catch length (size), which will be used to filter ( |
biomass |
Logical indicating whether biomass should be used to calculate harvest rates instead of abundance. |
model_selectivity |
Logical indicating whether to use model selectivity when calculating harvest rates. |
base_size |
Base size parameter for ggplot. See ggtheme. |
return_data |
Logical indicating whether to return data for the plot instead of the plot itself. |
The function uses all catches without filtering by size (but allocates them to substocks) and varies denominator depending on the min_catch_length argument. If min_catch_length = NULL, the output represents harvest rate for each substock assuming model fleet selectivities (fetched from the harv.biomass column in fit$res.by.year). If min_catch_length = 0, the output represents harvest rate for the entire model population assuming model fleet selectivities (fetched from the harv.biomass column in fit$res.by.year, stocks are summed before calculating the harvest rate). Finally, if min_catch_length is any number > 0, the output represents harvest rate assuming flat selectivity for lengths >= min_catch_length. Note that the last IS NOT real model harvest rate. It should only be used for reporting results, never for finding target harvest rates in projections, for instance. The min_catch_length = 0 is for the latter case.
A ggplot object.
data(fit) plot_hr(fit) plot_hr(fit, model_selectivity = FALSE) plot_hr(fit, min_catch_length = 45)data(fit) plot_hr(fit) plot_hr(fit, model_selectivity = FALSE) plot_hr(fit, min_catch_length = 45)
Plot central model output from a jitter analysis
plot_jitter( jitter_fit, vars = c("nll.summary", "total.biomass", "hr", "recruitment"), base_size = 8, ncol = NULL )plot_jitter( jitter_fit, vars = c("nll.summary", "total.biomass", "hr", "recruitment"), base_size = 8, ncol = NULL )
jitter_fit |
|
vars |
Character vector giving the variables to plot. Only the default parameters are currently implemented. |
base_size |
Base size parameter for ggplot. See ggtheme. |
ncol |
Number of columns to be used in the plot. Set to |
A ggplot object.
Plot model length distributions for stocks by year
plot_ldist( fit, type = "line", by_age = FALSE, stocks = NULL, scales = "fixed", ncol = NULL, years = NULL, base_size = 8 )plot_ldist( fit, type = "line", by_age = FALSE, stocks = NULL, scales = "fixed", ncol = NULL, years = NULL, base_size = 8 )
fit |
A gadget fit object. See |
type |
Character specifying the plot type. Options: |
by_age |
Logical indicating whether the length distributions should be grouped by age. Works only with |
stocks |
Character specifying the substock to plot in |
scales |
Character defining the |
ncol |
Number of columns passed to |
years |
Numeric vector defining which years to plot. If |
base_size |
Base size parameter for ggplot. See ggtheme. |
Do not trust the absolute numbers when by_age = TRUE. They are estimated from normal distributions by using number * dnorm(1:120, mean = mean_length, sd = stddev_length).
A ggplot object or a list of such objects depending on the type argument.
data(fit) plot_ldist(fit) plot_ldist(fit, type = "bar") plot_ldist(fit, type = "ggridges") plot_ldist(fit, by_age = TRUE, years = 2021)data(fit) plot_ldist(fit) plot_ldist(fit, type = "bar") plot_ldist(fit, type = "ggridges") plot_ldist(fit, by_age = TRUE, years = 2021)
Plot central model output from a leave-out analysis
plot_leaveout( lo_fit, vars = c("nll.summary", "total.biomass", "hr", "recruitment"), ncol = NULL, colors = NULL, base_size = 8, legend_title = "Left-out\ncomponent" )plot_leaveout( lo_fit, vars = c("nll.summary", "total.biomass", "hr", "recruitment"), ncol = NULL, colors = NULL, base_size = 8, legend_title = "Left-out\ncomponent" )
lo_fit |
A list of |
vars |
Character vector giving the variables to plot. Only the default parameters are currently implemented. |
ncol |
Number of columns to be used in the plot. Set to |
colors |
Vector of colors to use for leave-out component names. If a named vector, the component names are sorted following the order in the legend. |
base_size |
Base size parameter for ggplot. See ggtheme. |
legend_title |
Character speficfying the title for legend (color mapping) |
A ggplot object.
Plot likelihood summary
plot_likelihood( fit, type = "total", log_scale = FALSE, use_proportions = TRUE, base_size = 8 )plot_likelihood( fit, type = "total", log_scale = FALSE, use_proportions = TRUE, base_size = 8 )
fit |
A gadget fit object. See |
type |
Character specifying the plot type. Options: |
log_scale |
Logical indicating whether the value axis should be log10 transformed. |
use_proportions |
Logical indicating whether proportions of summed likelihood scores should be used instead of summed likelihood score values when |
base_size |
Base size parameter for ggplot. See ggtheme. |
Possible plot types are:
Plots direct comparisons of data with model output.
Plots the weighted likelihood value for each component.
Plots the sums of weighted and raw likelihood values by component.
A ggplot object.
data(fit) plot_likelihood(fit) plot_likelihood(fit, use_proportions = FALSE, log_scale = TRUE) plot_likelihood(fit, type = "weighted")data(fit) plot_likelihood(fit) plot_likelihood(fit, use_proportions = FALSE, log_scale = TRUE) plot_likelihood(fit, type = "weighted")
Plot parameter values relative to their boundaries
plot_param(fit, out_only = FALSE, base_size = 8)plot_param(fit, out_only = FALSE, base_size = 8)
fit |
A gadget fit object or a data frame containing model parameters. See |
out_only |
Logical indicating whether only parameters outside their boundaries should be plotted. |
base_size |
Base size parameter for ggplot. See ggtheme. |
The default plot is likely busy. Use plotly::ggplotly() to make it easier to interpret. If you are after parameters that are outside their boundaries, the out_only argument will help.
A ggplot object.
data(fit) plot_param(fit) plot_param(fit, out_only = TRUE)data(fit) plot_param(fit) plot_param(fit, out_only = TRUE)
Plot recruitment
plot_rec( fit, panelrow = FALSE, stocks = NULL, return_data = FALSE, base_size = 8, scale = c("millions", "billions", "thousands") )plot_rec( fit, panelrow = FALSE, stocks = NULL, return_data = FALSE, base_size = 8, scale = c("millions", "billions", "thousands") )
fit |
A gadget fit object. See |
panelrow |
something here |
stocks |
Character specifying the stock to plot in |
return_data |
Logical indicating whether to return data for the plot instead of the plot itself. |
base_size |
Base size parameter for ggplot. See ggtheme. |
scale |
Character specifying the display unit of recruitment: |
A ggplot object.
data(fit) plot_rec(fit) plot_rec(fit, stocks = "total")data(fit) plot_rec(fit) plot_rec(fit, stocks = "total")
Produces a residual plot for each catchdist.fleets component.
plot_resid(fit, base_size = 8)plot_resid(fit, base_size = 8)
fit |
A gadget fit object. See |
base_size |
Base size parameter for ggplot. See ggtheme. |
A ggplot object.
data(fit) plot_resid(fit)data(fit) plot_resid(fit)
Plot model biomass from a retrospective analysis
plot_retro( retro_fit, var = "total.biomass", by_stock = TRUE, min_catch_length = NULL, base_size = 8, ncol = NULL )plot_retro( retro_fit, var = "total.biomass", by_stock = TRUE, min_catch_length = NULL, base_size = 8, ncol = NULL )
retro_fit |
A list of |
var |
Character argument defining the variable to plot. Only |
by_stock |
Logical indicating whether to produce plots by stock in addition to total biomass. |
min_catch_length |
Numeric value defining the minimum catch length (size), which will be used to filter ( |
base_size |
Base size parameter for ggplot. See ggtheme. |
ncol |
Number of columns to be used in the plot. |
A ggplot object.
Plot survey indices
plot_si(fit, type = "model_fit", base_size = 8)plot_si(fit, type = "model_fit", base_size = 8)
fit |
A gadget fit object. See |
type |
Character specifying the plot type: |
base_size |
Base size parameter for ggplot. See ggtheme. |
Relationship between a survey index (I) and model biomass or abundance (B) over a defined length range is expressed as , where is the catchability (also called q) and b the stock size dependent catchability (see type = "model_fit"). Whether I is compared to model biomass or abundance, depends on the units of I (i.e. column name of the data object; "number" -> abundance, "weight" -> biomass). The survey index I is called "observed" in the figure, and "predicted" is derived as . The a and b can be visualized using a log-linear formula (see type = "regression"; log-linear regressions shown using blue lines). The coefficient of determination is calculated using this regression. To compare the observed and predicted values in the model fit plot, use type = "scatter". The grey line represents a diagonal line with a slope of 1 and intercept of 0 (i.e. , , ).
A ggplot object.
data(fit) plot_si(fit) plot_si(fit, type = "regression") plot_si(fit, type = "scatter")data(fit) plot_si(fit) plot_si(fit, type = "regression") plot_si(fit, type = "scatter")
Plots spawning stock biomass (SSB) against recruitment with a lag
plot_sr( fit, spawning_stock = NULL, lag = 1, years = NULL, add_line = TRUE, base_size = 8 )plot_sr( fit, spawning_stock = NULL, lag = 1, years = NULL, add_line = TRUE, base_size = 8 )
fit |
A gadget fit object. See |
spawning_stock |
Either character defining the name of the stock that should be understood as spawning stock, or numeric giving the minimum length of spawning fish. If |
lag |
Integer giving the number of time steps that should be used as a lag between SSB and recruitment. |
years |
A vector of recruitment years to include. If |
add_line |
Add a line connecting years |
base_size |
Base size parameter for ggplot. See ggtheme. |
A ggplot object or a list of such objects depending on the stocks argument.
data(fit) plot_sr(fit, spawning_stock = "ghl_female_mat") plot_sr(fit, spawning_stock = 45)data(fit) plot_sr(fit, spawning_stock = "ghl_female_mat") plot_sr(fit, spawning_stock = 45)
Plot spawning stock biomass
plot_ssb(fit, spawning_stock = NULL, base_size = 8)plot_ssb(fit, spawning_stock = NULL, base_size = 8)
fit |
A gadget fit object. See |
spawning_stock |
Character specifying the name of the spawning stock in the |
base_size |
Base size parameter for ggplot. See ggtheme. |
A ggplot object.
data(fit) plot_ssb(fit, spawning_stock = "ghl_female_mat")data(fit) plot_ssb(fit, spawning_stock = "ghl_female_mat")
Plots proportions of stocks in the model by length or age
plot_stockcomp(fit, type = "line", by_age = FALSE, base_size = 8)plot_stockcomp(fit, type = "line", by_age = FALSE, base_size = 8)
fit |
A gadget fit object. See |
type |
Character specifying the plot type. Options: "line" or "area". See examples. |
by_age |
Logical indicating whether age should be used on the x-axis instead of length |
base_size |
Base size parameter for ggplot. See ggtheme. |
A ggplot object or a list of such objects depending on the type argument.
data(fit) plot_stockcomp(fit) plot_stockcomp(fit, type = "area") plot_stockcomp(fit, by_age = TRUE)data(fit) plot_stockcomp(fit) plot_stockcomp(fit, type = "area") plot_stockcomp(fit, by_age = TRUE)
Plots proportions of stocks by length or age in fit$stockdist
plot_stockdist( fit, stocks = NULL, name = NULL, type = "step", show_intervals = FALSE, color_palette = "default", base_size = 8 )plot_stockdist( fit, stocks = NULL, name = NULL, type = "step", show_intervals = FALSE, color_palette = "default", base_size = 8 )
fit |
A gadget fit object. See |
stocks |
Character vector specifying the stock to plot in |
name |
Character vector specifying the likelihood component to plot in |
type |
Character specifying the plot type: |
show_intervals |
Logical indicating whether length intervals should be plotted. |
color_palette |
A function defining the color palette or a vector of colors to be used for stocks. |
base_size |
Base size parameter for ggplot. See ggtheme. |
Plots model fit to data using likelihoods. Separate plot for each unique(fit$stockdist$name).
A ggplot object or a list of such objects depending on the stocks argument.
data(fit) # Only one dataset to save space: plot_stockdist(fit, name = "EggaN_matp") plot_stockdist(fit, name = "EggaN_matp", stocks = "separate", color_palette = NULL) plot_stockdist(fit, name = "EggaN_matp", type = "line", show_intervals = TRUE)data(fit) # Only one dataset to save space: plot_stockdist(fit, name = "EggaN_matp") plot_stockdist(fit, name = "EggaN_matp", stocks = "separate", color_palette = NULL) plot_stockdist(fit, name = "EggaN_matp", type = "line", show_intervals = TRUE)
Plot suitability
plot_suitability( fit, fleets = "all", add_models = TRUE, include_missing = TRUE, base_size = 8 )plot_suitability( fit, fleets = "all", add_models = TRUE, include_missing = TRUE, base_size = 8 )
fit |
A gadget fit object. See |
fleets |
Character vector specifying the fleets to plot in |
add_models |
Logical indicating whether models using suitability parameters should be plotted together with the suitabilities estimated from data. The name of the parameter has to be similar to the fleet name. Uses grep and does not always work. |
include_missing |
Logical indicating whether years with missing catch data should be plotted. |
base_size |
Base size parameter for ggplot. See ggtheme. |
Fleets whose suitability depends on age (the suitability table has non-missing ages, e.g. a selectivity defined by age rather than length) are plotted against age instead of length, since such a fleet has one suitability value per age at every length. With fleets = "all" or several fleets, length- and age-based fleets cannot share an axis: if both are selected, the age-based ones are left out with a message.
A ggplot object. If fleet = NULL, a list of ggplot objects.
data(fit) plot_suitability(fit) plot_suitability(fit, fleets = "EggaN_survey", include_missing = FALSE)data(fit) plot_suitability(fit) plot_suitability(fit, fleets = "EggaN_survey", include_missing = FALSE)
Plot parameter weights
plot_weight(fit, log_scale = FALSE, base_size = 8)plot_weight(fit, log_scale = FALSE, base_size = 8)
fit |
A gadget fit object. See |
log_scale |
Logical indicating whether the value axis should be log10 transformed. |
base_size |
Base size parameter for ggplot. See ggtheme. |
A ggplot object.
data(fit) plot_weight(fit) plot_weight(fit, log_scale = TRUE)data(fit) plot_weight(fit) plot_weight(fit, log_scale = TRUE)
gadget.fit objectA wrapper function to plot the results from a gadget.fit object.
## S3 method for class 'gadget.fit' plot(x, param = "annual", ...)## S3 method for class 'gadget.fit' plot(x, param = "annual", ...)
x |
A gadget fit object. See |
param |
Character defining the parameter to plot. See Details. |
... |
Additional parameters passed to the separate plotting functions. |
A wrapper to plot the results from a gadget.fit object. The function produces a different plots defined by param argument and additional arguments passed to the respective functions.
Valid param options are:
Annual summary of central model data. Uses plot_annual
Stock biomass. Uses plot_biomass
Stock biomass with total. Uses plot_biomass(..., total = TRUE)
Stock abundance. Uses plot_biomass(..., biomass = FALSE)
Spawning stock biomass. Uses plot_ssb
Recruitment. Uses plot_rec
Fishing mortality. Uses plot_f
Catches by stock. Uses plot_catch(..., type = "stock")
Catches by fleet. Uses plot_catch(..., type = "fleet")
Harvest rate. Uses plot_catch(..., type = "hr")
Survey indices. Uses plot_si
Catch distribution comparison to data. Uses plot_catchdist
Stock distribution comparison to data. Uses plot_stockdist
Model stock composition. Uses plot_stockcomp
Suitability (fleet selection). Uses plot_suitability
Average length by age. Uses plot_growth
Age-length (growth parameter) fit. Uses plot_agelength
Age composition. Uses plot_agecomp
Residuals. Uses plot_resid
Likelihood scores. Uses plot_likelihood
Weighted likelihood scores. Uses plot_likelihood(..., type = "weighted")
Proportion of summed weighted likelihood scores. Uses plot_likelihood(..., type = "pie")
Parameter component weights
Parameter values relative to their boundaries
Single or a list of ggplot objects depending on the arguments.
Sex input data to gadget
sexratio_examplesexratio_example
Data frame with gadget attributes containing Greenland halibut sex distributions (i.e. sex at length data) from the Barents Sea Ecosystem Survey.
Joint Russian-Norwegian Arctic Fisheries Working Group
Other datasets:
aldist_example,
example_catches,
fit,
ldist_example,
stockdist_example
Maturity input data to gadget
stockdist_examplestockdist_example
Data frame with gadget attributes containing Greenland halibut stock distributions (i.e. maturity and sex at length data) from the Institute of Marine Research EggaNord survey.
Joint Russian-Norwegian Arctic Fisheries Working Group
Other datasets:
aldist_example,
example_catches,
fit,
ldist_example,
sexratio_example