Skip to content

[feat]: enable user to add a reference line to the plot for each input dat - #315

Open
Schiano-NOAA wants to merge 19 commits into
mainfrom
feat-mult-refline
Open

[feat]: enable user to add a reference line to the plot for each input dat#315
Schiano-NOAA wants to merge 19 commits into
mainfrom
feat-mult-refline

Conversation

@Schiano-NOAA

Copy link
Copy Markdown
Collaborator

I moved the reference line portion of the plot into it's own function -- add_reference_line() -- which gets added to the plot using the (+) operator.

This feature automatically applies to each input dat. There are 4 conditions that this feature handles

  1. reference lines and values extracted for each input dat. e.g.
    plot_spawning_biomass(dat=list("mod1"=mod1, "mod2"=mod2), ref_line = "msy") SBmsy is found for each model.
  2. custom values are input by the user for each model in order they are listed in dat. e.g. plot_spawning_biomass(dat=list("mod1"=mod1, "mod2"=mod2), ref_line = c("msy"=1000, "msy"=1200)) In this instance, any name or combinations can be used as long as there is one value for each element in the dat list.
  3. different reference lines for each model extracted automatically. e.g. plot_spawning_biomass(dat=list("mod1"=mod1, "mod2"=mod2), ref_line = c("msy","target"))
  4. Don't include lines at all. Set ref_line = NULL

@github-actions

Copy link
Copy Markdown
Contributor

New version checklist

  • Package version in DESCRIPTION has been updated
  • Release notes have been drafted/published
  • Cheatsheet content has been updated (if applicable)
  • Cheatsheet version has been updated

@Schiano-NOAA
Schiano-NOAA marked this pull request as ready for review July 30, 2026 19:15

@sbreitbart-NOAA sbreitbart-NOAA left a comment

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.

This feature is going to be so useful and important! Also great to see repeated code removed in favor of making a streamlined function useful for these and future plots.

I have some questions and suggestions. This functions as expected in most ways, but I think there are a few tasks left to do- like making sure this works and is documented clearly for various situations.

Comment thread R/plot_fishing_mortality.R Outdated
Comment thread R/plot_fishing_mortality.R
Comment thread R/utils_plot.R Outdated
Comment thread R/plot_spawning_biomass.R Outdated
Comment thread R/utils_plot.R
Comment thread R/utils_plot.R
Comment thread R/utils_plot.R
Comment thread R/utils_plot.R
Comment thread R/plot_biomass.R
dat = rp_dat,
label_name = "biomass",
reference = ref_line,
final <- plt +

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.

I like the messages shown when a ref line isn't found. Here, it shows up for one model but not both, even though zero ref lines are shown (i.e., no message warning about a lack of ref line for the stockplotr example data, but it's not shown):

plot_biomass(dat = list("petrale" = dat, "skate" = skate), module = "TIME_SERIES")
! biomass_msy not found for skate
Warning messages:
1: Removed 1 row containing missing values or values
outside the scale range (geom_hline()).
2: Removed 1 row containing missing values or values
outside the scale range (geom_text()).

Image

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.

That's interesting because it should show for both if both don't appear. It's in a loop

Comment thread R/utils_plot.R
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

For all applicable plots: add ability to show ref_line for each model

2 participants