Skip to content

Adds plot_data_availability() - #482

Open
ericward-noaa wants to merge 1 commit into
nmfs-ost:mainfrom
ericward-noaa:more-fims-plots-data-availability
Open

ericward-noaa wants to merge 1 commit into
nmfs-ost:mainfrom
ericward-noaa:more-fims-plots-data-availability

Conversation

@ericward-noaa

@ericward-noaa ericward-noaa commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

What is the feature?

This function has nothing to do with model output, but just focused on data following the general format of
SSplotData in r4ss
dataplot in SAM
plotspict.data() in spict

How have you implemented the solution?

  • Added the function plot_data_availability that shows presence/absence of data for different data types (rows) across time (years) with square boxes.

Does the PR impact any other area of the project, maybe another repo?

  • PR is off of main, doesn't affect any other PRs. I have included the key quantities etc here following the other plots that have been added. Examples with example_data and vermilion_snapper are below
data_example_2 data_example

PR contribution checklist

Thank you for contributing to stockplotr! Please check the boxes below to confirm this pull request (PR) is ready for review. Edit this PR description to add the release indicator and any explanations.

  • I have read and adhered to the contributor guide.
  • I have kept this PR focused on one plot where applicable. For multiple features, I have used separate PRs (stacked PRs are welcome if needed).
  • I have aimed to keep this PR to no more than 750 lines, excluding tests and example data (for example, up to 750 lines for a new function).
  • If I have provided an example dataset, I have explained why the existing sample datasets are not sufficient.
  • I have tested that my changes are compatible with all example outputs in the "data" folder (example_data.rda; pollock.rda; ss3_simple.rda; vermilion_snapper.rda).
  • If I didn't follow the development workflow, I have explained why in this PR.
  • If applicable, I've added the plot to save_all_plots() and updated the associated tests in test-save_all_plots.R.
  • After opening this PR, I have checked that my own tests and spellcheck pass (spelling::spell_check_package()). If other checks fail, I have flagged them for the package maintainers to help diagnose and remedy.
  • I have requested review from one package maintainer (Sam or Sophie).

Follows
SSplotData in r4ss
dataplot in SAM
plotspict.data() in spict
@ericward-noaa

Copy link
Copy Markdown
Contributor Author

@sbreitbart-NOAA @Schiano-NOAA This is ready for review

@kellijohnson-NOAA

Copy link
Copy Markdown
Collaborator

@ericward-noaa would this plot be something we could use as a plot method for the FIMSFrame class in {FIMS} (current code lives here)?

@iantaylor-NOAA

Copy link
Copy Markdown
Contributor

@ericward-noaa, thank you for adding this. The plots are beautiful.
Kelli beat me by a minute to make the same suggestion. Having the same plot for both FIMS input and output (from any model) would be excellent and hopefully not too big a lift.

Someday it would be nice to have an alternative with bubbles scaled by sample sizes or uncertainty but given the in-flux specification of uncertainty in FIMS, I think that would be a good idea to wait on that.

Last suggestion: what do you think about putting the fleet names to the right-hand axis (leaving the data types on the left)?

@iantaylor-NOAA

Copy link
Copy Markdown
Contributor

I have two more suggestions after testing the plot on a model with lots of fleets and years via the commands below which created the plot below.

canary_ss3 <- r4ss::SS_output(
    "https://raw.githubusercontent.com/pfmc-assessments/canary_2023/refs/heads/main/models/7_3_5_reweight/"
)
canary_converted <- stockplotr::convert_output(canary_ss3)
plot_data_availability(canary_converted) |>
    ggplot2::ggsave(filename = 'data.png', height = 10, width = 10)
  1. Trivial change: add line breaks to "Age compositions" and "Length compositions" to save a little horizontal space.

  2. Allow the order of the fleets to be specified, rather than alphabetical. Adding this block after line 158 seems to work to allow the user to specify the vector of fleet names in the order they want (e.g. via plot_data_availability(canary_converted, fleet = canary_ss3$FleetNames)). I'm not sure if there's a way to get the original fleet name order from the data by default since it depends on the data types used for each fleet.

    avail$fleet <- factor(
      avail$fleet,
      levels = unique(fleet[fleet %in% avail$fleet])
    )
data

This branch has not been deployed

No deployments
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.

3 participants