Plot Total Biomass
plot_biomass(
dat,
geom = "line",
group = NULL,
facet = NULL,
ref_line = "msy",
unit_label = "metric tons",
module = NULL,
scale_amount = 1,
relative = FALSE,
make_rda = FALSE,
figures_dir = getwd(),
interactive = TRUE,
...
)A data frame or names list of data frames (input as `list()`) returned from convert_output. The first data frame in the list is used in calculation of a reference line if one is present
A string stating the geom used for the plot. Default is "line". Options include "line", "point", or "area"
a string of a single column that groups the data (e.g. "fleet", "sex", "area", etc.). Currently can only have one level of grouping. If you want to just summarize the data across all factors, set group = "none". In the case there is only one unique value of the grouping and/or NA is available, the function will default to the NAs and in some cases the grouping when there is not an equal number of rows for NA and the grouped data.
a string or vector of strings of a column that facets the data (e.g. "year", "area", etc.)
A string specifying the type of reference you want to compare biomass to. The default is `"msy"`, which looks for `"biomass_msy"` in the `"label"` column of `dat`. The actual searching in `dat` is case agnostic and will work with either upper- or lower-case letters but you must use one of the options specified in the default list to ensure that the label on the figure looks correct regardless of how it is specified in `dat`. Other possibilities may include "target", "MSY", and "unfished".
units for biomass
(Optional) A string indicating the linked module_name associated with the label for the plot if known. Default is NULL. By default, the function will select the most relevant module if more than 1 exists.
A number describing how much to scale down the quantities shown on the y axis. For example, scale_amount = 100 would scale down a value from 500,000 –> 5,000. This scale will be reflected in the y axis label.
A logical value specifying if the resulting figures should be relative spawning biomass. The default is `FALSE`. `ref_line` indicates which reference point to use.
TRUE/FALSE; indicate whether to produce an .rda file containing a list with the figure/table, caption, and alternative text (if figure). If TRUE, the rda will be exported to the folder indicated in the argument "figures_dir". Default is FALSE.
The location of the folder containing the generated figure rda files ("figures") that will be created if the argument `make_rda` = TRUE. Default is the working directory.
TRUE/FALSE; indicate whether the environment in which the function is operating is interactive. This bypasses some options for filtering when preparing data for the plot. Default is FALSE.
Arguments called from ggplot2::geom_line or ggplot2::geom_point
Plot total biomass from a stock assessment model as found in a NOAA stock assessment report. Units of total biomass can either be manually added or will be extracted from the provided file if possible. There are options #' to return a [ggplot2::ggplot()] object or export an rda object containing associated caption and alternative text for the figure.
plot_biomass(
dat = stockplotr:::example_data,
unit_label = "mt",
ref_line = "target",
scale_amount = 100,
module = "TIME_SERIES",
figures_dir = getwd()
)
#> Ignoring unknown labels:
#> • shape : "Fleet"
#> Warning: Removed 1 row containing missing values or values outside the scale range
#> (`geom_hline()`).
#> Warning: Removed 1 row containing missing values or values outside the scale range
#> (`geom_text()`).
plot_biomass(
dat = stockplotr:::example_data,
facet = "fleet",
ref_line = "target",
module = "TIME_SERIES",
figures_dir = getwd()
)
#> Ignoring unknown labels:
#> • shape : "Fleet"
#> Warning: Removed 2 rows containing missing values or values outside the scale range
#> (`geom_hline()`).
#> Warning: Removed 2 rows containing missing values or values outside the scale range
#> (`geom_text()`).