Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Nov 16, 2025

The wlim and ylim arguments in plotBiomass() and plotSpectra() only filtered data, not the actual axis ranges. This prevented visual comparison of plots with fixed axes (e.g., using diffviewer).

Changes

  • plotDataFrame(): Added xlim/ylim parameters (default c(NA, NA)), passed to scale_x_continuous()/scale_y_continuous()
  • plotBiomass(): Passes ylim through to plotDataFrame()
  • plot_spectra(): Passes wlim as xlim and ylim to plotDataFrame()
  • Tests: Verify limits are set correctly with NA and non-NA combinations

Data filtering behavior is preserved. NA values auto-scale to data range.

Example

# Compare plots with fixed y-axis
sim1 <- project(params, effort = 0.5, t_max = 20)
sim2 <- project(params, effort = 1.5, t_max = 20)

plotBiomass(sim1, species = "Cod", ylim = c(1e4, 1e10))
plotBiomass(sim2, species = "Cod", ylim = c(1e4, 1e10))
# Both plots now have identical axis ranges

# Partial specification
plotBiomass(sim, ylim = c(NA, 1e8))  # Auto lower limit, fixed upper

Fixes #194

Original prompt

This section details on the original issue you should resolve

<issue_title>Allow user to specify range on axes in plots</issue_title>
<issue_description>Even functions that have a ylim argument only use it to subselect the data, not to specify the limits on the axis. The wlim and ylim arguments would need to be passed to plotDataFrame() and used there to set the axis limits.

Being able to fix the axes would be important for example for visually comparing two plots with diffviewer, see #194.</issue_description>

Comments on the Issue (you are @copilot in this section)


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI changed the title [WIP] Allow user to specify range on axes in plots Set actual axis limits when wlim/ylim specified in plots Nov 16, 2025
Copilot AI requested a review from gustavdelius November 16, 2025 14:31
@gustavdelius gustavdelius marked this pull request as ready for review November 16, 2025 16:53
@gustavdelius gustavdelius merged commit cfa89f2 into master Nov 16, 2025
0 of 5 checks passed
@gustavdelius gustavdelius deleted the copilot/allow-axis-range-in-plots branch November 16, 2025 16:54
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.

Allow user to specify range on axes in plots New way to visually compare two plots

2 participants