Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
763ec0a
refactor: pull interactive selection code into function for reuse acr…
JZahner1 Nov 17, 2026
53c4f79
refactor: use filter_interactive for module_name selection
JZahner1 Nov 17, 2026
a333b92
feat: allow for interactive selection of model
JZahner1 Nov 17, 2026
d14d104
feat: allow for interactive model selection for all plotting functions
JZahner1 Nov 17, 2026
fefe960
fix: fix error where projection tables only showing data from first f…
JZahner1 Nov 17, 2026
523f4bf
feat: allow for interactive model selection for all table functions
JZahner1 Nov 17, 2026
e63b3f2
tests: add tests for interactive model selection
JZahner1 Nov 17, 2026
10ead1c
dcocs: update roxygen with model parameter
JZahner1 Nov 17, 2026
46c55f6
Merge branch 'main' into feat-interactive-model-selection2
JZahner1 Nov 17, 2026
fa5a5a1
minor docs/code cleanup from review
JZahner1 Nov 17, 2026
525893d
docs: update documentation with `model` parameter
JZahner1 Nov 17, 2026
c455b20
docs: update roxygen for interactive filtering
JZahner1 Nov 17, 2026
d4dc8fb
Update variable names for better readability
JZahner1 Nov 18, 2026
e8dbc42
docs: correct missing documentation
JZahner1 Nov 18, 2026
83f2e1b
[fix]: disable multi model selection for table_index
JZahner1 Nov 18, 2026
4b1ac58
Merge branch 'main' into feat-interactive-model-selection2
JZahner1 Nov 18, 2026
56e99dd
fix: fix bug when making multiple selections INCLUDING "All"
JZahner1 Nov 18, 2026
c8e7177
fix: make sure only first value ends up selectd if multiple supplied …
JZahner1 Nov 18, 2026
7d3fe3b
fix: pass model on to filter_data in table_total_catch
JZahner1 Nov 18, 2026
ba4e1a9
fix: handle multiple reference lines in plot_biomass when multiple mo…
JZahner1 Nov 18, 2026
cf9fe02
fix: can't use model="All" directly with `filter_data`
JZahner1 Nov 18, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion R/plot_abundance_at_age.R
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,13 @@
#'
#' If the interactive and >1 module_name is found, user will select the
#' module_name in the console. @seealso [filter_data()]
#' @param model Character vector. (Optional) Model name found in `dat$model`.
#' If selecting >1 model, place them in a vector like c("model1", "model2").
#'
#' Default: NULL
#'
#' If the interactive and >1 model is found, user will select the
#' model in the console. @seealso [filter_data()]
#' @param interactive A logical value indicating if the environment is interactive.
#'
#' Default: `FALSE`
Expand Down Expand Up @@ -81,6 +88,7 @@ plot_abundance_at_age <- function(
scale_amount = 1,
proportional = TRUE,
module = NULL,
model = NULL,
Comment thread
JZahner1 marked this conversation as resolved.
Resolved
interactive = TRUE,
make_rda = FALSE,
figures_dir = getwd()
Expand All @@ -94,8 +102,10 @@ plot_abundance_at_age <- function(
geom = "point",
group = "age",
module = module,
model = model,
scale_amount = scale_amount,
interactive = interactive
interactive = interactive,
allow_multiple_models = TRUE
)

# Create label for abundance units in legend
Expand Down
7 changes: 5 additions & 2 deletions R/plot_biomass.R
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ plot_biomass <- function(
era = NULL,
unit_label = NULL,
module = NULL,
model = NULL,
scale_amount = 1,
relative = FALSE,
make_rda = FALSE,
Expand Down Expand Up @@ -84,8 +85,10 @@ plot_biomass <- function(
facet = facet,
era = era,
module = module,
model = model,
Comment thread
sbreitbart-NOAA marked this conversation as resolved.
Resolved
scale_amount = scale_amount,
interactive = interactive
interactive = interactive,
allow_multiple_models = TRUE
)

if (is.null(unit_label)) {
Expand Down Expand Up @@ -155,7 +158,7 @@ plot_biomass <- function(
} else {
final <- plt +
add_reference_line(
dat = dat,
dat = dat |> dplyr::filter(model %in% selected_model),
ref_line = ref_line,
label = "biomass",
scale_amount = scale_amount
Expand Down
5 changes: 4 additions & 1 deletion R/plot_biomass_at_age.R
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ plot_biomass_at_age <- function(
scale_amount = 1,
proportional = TRUE,
module = NULL,
model = NULL,
interactive = TRUE,
make_rda = FALSE,
figures_dir = getwd()
Expand All @@ -61,8 +62,10 @@ plot_biomass_at_age <- function(
group = "age",
era = "time",
module = module,
model = model,
scale_amount = scale_amount,
interactive = interactive
interactive = interactive,
allow_multiple_models = TRUE
)

if (is.null(unit_label)) {
Expand Down
5 changes: 4 additions & 1 deletion R/plot_catch_at_age.R
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ plot_catch_at_age <- function(
proportional = TRUE,
interactive = TRUE,
module = NULL,
model = NULL,
make_rda = FALSE,
figures_dir = getwd()
) {
Expand All @@ -89,7 +90,9 @@ plot_catch_at_age <- function(
group = "age",
scale_amount = scale_amount,
interactive = interactive,
module = module
module = module,
model = model,
allow_multiple_models = TRUE
)
if (is.null(unit_label)) {
unit_label <- unique(catch$unit)
Expand Down
5 changes: 4 additions & 1 deletion R/plot_discard.R
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ plot_discard <- function(
scale_amount = 1,
interactive = TRUE,
module = NULL,
model = NULL,
predicted = TRUE,
interval = 0.95,
tolerance = 0.001,
Expand Down Expand Up @@ -115,8 +116,10 @@ plot_discard <- function(
group = group,
facet = facet,
module = module,
model = model,
scale_amount = scale_amount,
interactive = interactive
interactive = interactive,
allow_multiple_models = TRUE
)

# extract unit if unit_label is null and set lbs to F by default
Expand Down
5 changes: 4 additions & 1 deletion R/plot_fishing_mortality.R
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ plot_fishing_mortality <- function(
ref_line = "msy",
era = NULL,
module = NULL,
model = NULL,
make_rda = FALSE,
figures_dir = getwd(),
interactive = TRUE,
Expand All @@ -54,8 +55,10 @@ plot_fishing_mortality <- function(
group = group,
facet = facet,
module = module,
model = model,
scale_amount = 1,
interactive = interactive
interactive = interactive,
allow_multiple_models = TRUE
)
# Process data
processed_data <- process_data(
Expand Down
5 changes: 4 additions & 1 deletion R/plot_index.R
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ plot_index <- function(
facet = NULL,
interactive = TRUE,
module = NULL,
model = NULL,
focus = NULL,
interval = 0.95,
log = FALSE,
Expand Down Expand Up @@ -110,7 +111,9 @@ plot_index <- function(
group = group,
facet = facet,
interactive = interactive,
module = module
module = module,
model = model,
allow_multiple_models = TRUE
)

# There's 3 cases handled here
Expand Down
5 changes: 4 additions & 1 deletion R/plot_landings.R
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ plot_landings <- function(
era = NULL,
scale_amount = 1,
module = NULL,
model = NULL,
interactive = TRUE,
predicted = TRUE,
interval = 0.95,
Expand Down Expand Up @@ -136,8 +137,10 @@ plot_landings <- function(
group = group,
facet = facet,
module = module,
model = model,

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems worth looking into, though may be moot or different after rebasing with the main branch, which has Eric's PR merged in now

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Im not sure I really understand this comment...

scale_amount = scale_amount,
interactive = interactive
interactive = interactive,
allow_multiple_models = TRUE
)

# Intervals from the observation error of the observed and predicted
Expand Down
5 changes: 4 additions & 1 deletion R/plot_natural_mortality.R
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ plot_natural_mortality <- function(
era = NULL,
interactive = TRUE,
module = NULL,
model = NULL,
make_rda = FALSE,
figures_dir = getwd(),
...
Expand All @@ -43,7 +44,9 @@ plot_natural_mortality <- function(
facet = facet,
geom = "line",
interactive = interactive,
module = module
module = module,
model = model,
allow_multiple_models = TRUE
)

# Set group back to NULL if it is age since this is an at age plot
Expand Down
5 changes: 4 additions & 1 deletion R/plot_recruitment.R
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ plot_recruitment <- function(
# relative = FALSE,
interactive = TRUE,
module = NULL,
model = NULL,
make_rda = FALSE,
figures_dir = getwd()
) {
Expand All @@ -57,7 +58,9 @@ plot_recruitment <- function(
facet = facet,
interactive = interactive,
module = module,
scale_amount = scale_amount
model = model,
scale_amount = scale_amount,
allow_multiple_models = TRUE
)
# process data
processed_data <- process_data(
Expand Down
5 changes: 4 additions & 1 deletion R/plot_recruitment_deviations.R
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
plot_recruitment_deviations <- function(
dat,
module = NULL,
model = NULL,
era = NULL,
interactive = TRUE,
make_rda = FALSE,
Expand All @@ -46,10 +47,12 @@ plot_recruitment_deviations <- function(
dat = dat,
label_name = "recruitment_deviations",
module = module,
model = model,
era = era,
interactive = interactive,
geom = "point",
group = NULL
group = NULL,
allow_multiple_models = TRUE
)
# Process data
processed_data <- process_data(
Expand Down
8 changes: 3 additions & 5 deletions R/plot_retrospective.R
Original file line number Diff line number Diff line change
Expand Up @@ -141,9 +141,9 @@ plot_retrospective <- function(
func_pars <- list(
dat = retro_dat,
group="peel",
model = "All", # turn this on to bypass interactive model selection and plot all available models
make_rda=FALSE, # don't want to overwrite files from non-retro plots
...
model = names(end_years), # turn this on to bypass interactive model selection and plot all available models
make_rda=FALSE # don't want to overwrite files from non-retro plots
# ...
)

plt <- do.call(func_name, func_pars)
Expand Down Expand Up @@ -226,5 +226,3 @@ plot_retrospective <- function(
plt

}

# plot_retrospective(dat)
5 changes: 4 additions & 1 deletion R/plot_selectivity.R
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ plot_selectivity <- function(
facet = NULL,
interactive = TRUE,
module = NULL,
model = NULL,
make_rda = FALSE,
figures_dir = getwd(),
...
Expand All @@ -52,7 +53,9 @@ plot_selectivity <- function(
group = group,
facet = facet,
interactive = interactive,
module = module
module = module,
model = model,
allow_multiple_models = TRUE
)

if (is.null(unit_label)) {
Expand Down
15 changes: 13 additions & 2 deletions R/plot_spawning_biomass.R
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,13 @@
#'
#' If the interactive and >1 module_name is found, user will select the
#' module_name in the console. @seealso [filter_data()]
#' @param model Character vector. (Optional) Model name found in `dat$model`.
#' If selecting >1 model, place them in a vector like c("model1", "model2").
#'
#' Default: NULL
#'
#' If the interactive and >1 model is found, user will select the
#' model in the console. @seealso [filter_data()]
#' @param scale_amount Number. A number to scale the y-axis values. If > 1, the
#' magnitude of the scale amount will be added to the unit label
#' (e.g. scale_amount = 1000 with a unit label of "1000s of lbs" will result
Expand Down Expand Up @@ -132,6 +139,7 @@ plot_spawning_biomass <- function(
era = NULL,
lbs = lifecycle::deprecated(),
module = NULL,
model = NULL,
scale_amount = 1,
relative = FALSE,
make_rda = FALSE,
Expand All @@ -155,8 +163,10 @@ plot_spawning_biomass <- function(
group = group,
facet = facet,
module = module,
model = model,
scale_amount = scale_amount,
interactive = interactive
interactive = interactive,
allow_multiple_models = TRUE
)
# extract unit if unit_label is null and set lbs to F by default
lbs <- FALSE
Expand Down Expand Up @@ -221,7 +231,7 @@ plot_spawning_biomass <- function(
} else {
final <- plt +
add_reference_line(
dat = dat,
dat = dat |> dplyr::filter(model %in% selected_model),
ref_line = ref_line,
label = "spawning_biomass",
lbs = lbs,
Expand Down Expand Up @@ -308,6 +318,7 @@ plot_spawning_biomass <- function(

if (exists("selected_module")) {
rm(selected_module, envir = .GlobalEnv)
rm(selected_model, envir = .GlobalEnv)
}

# Output final plot
Expand Down
5 changes: 4 additions & 1 deletion R/plot_spr.R
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ plot_spr <- function(
ref_line = "target",
era = "time",
module = NULL,
model = NULL,
interactive = TRUE,
make_rda = FALSE,
figures_dir = getwd(),
Expand All @@ -59,8 +60,10 @@ plot_spr <- function(
group = group,
facet = facet,
module = module,
model = model,
scale_amount = 1,
interactive = interactive
interactive = interactive,
allow_multiple_models = TRUE
) |>
# filter NA from year
dplyr::filter(!is.na(year))
Expand Down
5 changes: 4 additions & 1 deletion R/plot_stock_recruitment.R
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ plot_stock_recruitment <- function(
interactive = TRUE,
era = NULL,
module = NULL,
model = NULL,
scale_amount = 1,
make_rda = FALSE,
figures_dir = getwd()
Expand All @@ -58,7 +59,9 @@ plot_stock_recruitment <- function(
geom = "point",
scale_amount = scale_amount,
interactive = interactive,
module = module
module = module,
model = model,
allow_multiple_models = TRUE
) |>
# filter for year !na
dplyr::filter(
Expand Down
Loading
Loading