Skip to content

Streamline plotting code and unify array comparison methods - #541

Merged
gustavdelius merged 3 commits into
length-axis-totalfrom
refactor-plotting-streamline
Aug 16, 2026
Merged

Streamline plotting code and unify array comparison methods#541
gustavdelius merged 3 commits into
length-axis-totalfrom
refactor-plotting-streamline

Conversation

@gustavdelius

Copy link
Copy Markdown
Member

Summary of Changes

This pull request streamlines the plotting codebase and makes method behaviours more uniform, logical, and maintainable on top of PRs #538, #539, and #540:

1. Resource Array Method Symmetry

  • Added size_axis, llim, per_log_size, array_log_y(), array_ylim(), and unit-aware axis labelling helpers (plot_size_xlab(), plot_size_xlim()) across plot2(), plotRelative(), and addPlot() for both ArrayResourceBySize and ArrayTimeByResourceBySize.
  • Resource spectra comparisons and multi-panel additions now have full symmetry with species array plotting methods.

2. Uniform Proportion Array Scaling

  • Added array_log_y() and array_ylim() to plot2.ArraySpeciesBySize, plot2.ArrayTimeBySpecies, and animate.ArrayTimeBySpeciesBySize.
  • Proportion arrays uniformly default to linear [0, 1] y-axes (widening to accommodate data when needed) across both single and comparison plots.

3. plotYield Streamlining & Redundant Parser Removal

  • Replaced the duplicate internal helper parseTimePlotLog with parsePlotLog across plotBiomass and plotYieldGear.
  • Streamlined plotYield.MizerSim so that a single simulation delegates directly to plot(getYield(object)) (setting value_name = "Yield" for proper labelling).
  • Formalized deprecation of the two-simulation sim2 argument of plotYield() with lifecycle::deprecate_warn("2.6.0", "plotYield(sim2)", "plot2()", details = "Use plot2(getYield(sim1), getYield(sim2)) instead.").

4. Length-axis Total Calculation

  • Gated plot_cdf() with validParams(params) so that missing length–weight coefficients a and b are resolved before conversion.
  • Updated plot_cdf(), plotSpectra2(), plotSpectraRelative(), and plotCDF2() to properly evaluate species-specific length conversions before computing total curves and normalisations.

5. plotFeedingLevel & plotlyFeedingLevel Refactoring

  • Refactored plotFeedingLevel() to delegate directly to plot() and addPlot() on ArraySpeciesBySize, using non-clipping cartesian coordinate limits for proportion ranges.
  • Simplified plotlyFeedingLevel() to plotHover(plotFeedingLevel(...)).

6. Testing & Documentation

  • Added test coverage in tests/testthat/test-ArrayResourceBySize-class.R and tests/testthat/test-plots.R.
  • Updated NEWS.md and package documentation.

Testing

  • All tests pass (484 tests in test-plots.R, 91 in array classes, and full test suite passing cleanly).

- Add size_axis, llim, per_log_size, and proportion scaling support to ArrayResourceBySize and ArrayTimeByResourceBySize plotting methods (plot2, plotRelative, addPlot), achieving full symmetry with species arrays.
- Add array_log_y() and array_ylim() to plot2.ArraySpeciesBySize, plot2.ArrayTimeBySpecies, and animate.ArrayTimeBySpeciesBySize so proportion arrays default to linear [0, 1] y-axes uniformly.
- Streamline plotYield.MizerSim to delegate single-simulation plotting directly to plot(getYield(sim)) and deprecate the two-simulation sim2 argument in favour of plot2(getYield(sim1), getYield(sim2)).
- Remove redundant internal parseTimePlotLog in favour of parsePlotLog.
- Refactor plotFeedingLevel to delegate to plot() and addPlot() on ArraySpeciesBySize, with non-clipping cartesian coordinates for proportion ranges, and simplify plotlyFeedingLevel to plotHover(plotFeedingLevel(...)).
- Ensure length-axis Total calculation in plot_cdf(), plotSpectra2(), plotSpectraRelative(), and plotCDF2() properly evaluates species-specific conversions before total aggregation.
- Add tests covering resource array methods on length/log-size axes, comparison totals, and feeding level delegation.
@gustavdelius
gustavdelius force-pushed the refactor-plotting-streamline branch from 18c1472 to 4237b22 Compare August 16, 2026 08:06
@gustavdelius
gustavdelius merged commit b88b8f4 into master Aug 16, 2026
@gustavdelius
gustavdelius deleted the refactor-plotting-streamline branch August 16, 2026 08: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