Skip to content

[codex] Add length axis option to size plots#345

Open
gustavdelius wants to merge 3 commits into
masterfrom
length-axis-plots
Open

[codex] Add length axis option to size plots#345
gustavdelius wants to merge 3 commits into
masterfrom
length-axis-plots

Conversation

@gustavdelius
Copy link
Copy Markdown
Member

Summary

Adds size_axis = c("w", "l") to size-based plotting APIs so users can show length in cm instead of weight in grams on the size axis. Length values are derived from the species-specific allometric weight-length relationship via the existing w2l() helper.

Details

  • Keeps size_axis = "w" as the default to preserve existing plot behaviour.
  • Applies length axes to spectra, CDF, feeding level, predation mortality, fishing mortality, diet, generic size-array plots, comparison helpers, plotly wrappers, and animations.
  • Omits Resource and Total curves for length-axis plots because they do not have a species-specific weight-length relationship.
  • Updates return_data = TRUE output so the plotted size column is l when size_axis = "l".
  • Updates documentation, NEWS, and focused plot tests.

Validation

  • devtools::load_all(); testthat::test_file("tests/testthat/test-plots.R")
  • Smoke-tested plotlySpectra(..., size_axis = "l") and animate(..., size_axis = "l").

Copy link
Copy Markdown
Member Author

Fixed the example-check failure from plot2(getBiomass(...), getBiomass(...)).

Root cause: the shared comparison helpers were defaulting to size-axis conversion and assumed a w column, even for time-series comparisons whose x column is Year. They now only perform w/l conversion when a caller explicitly passes size_axis.

Validation rerun:

  • devtools::load_all(); testthat::test_file("tests/testthat/test-plots.R")
  • Exact failing example commands from plot2 documentation now print without error.

Copy link
Copy Markdown
Member Author

Fixed the Rd warning for plotSpectraRelative.Rd: size_axis is now documented in the roxygen block and the Rd file has been regenerated.

Updated branch head: 07266b85.

@gustavdelius gustavdelius marked this pull request as ready for review May 23, 2026 07:09
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.

1 participant