Skip to content

Conversation

@r3kste
Copy link
Collaborator

@r3kste r3kste commented Oct 18, 2025

Summary of changes

  1. Added grid_line_plot function that takes a list[list[LineData]] and returns a grid plot.
  2. Modified line_plot to take in an optional parameter subplot. This allows grid_line_plot to re use line_plot functionality.
  3. Refactored convergence_plot to use the backend plotting.

Plot Changes

Before After
old new

Backend Comparision

Plotly Matplotlib
new output

PR Checklist

  • Compared images before and after making changes
  • Tests
  • Documentation

@r3kste r3kste force-pushed the convergence_plot_refactor branch from 49b18fd to 1cbe6df Compare October 18, 2025 08:29
@codecov
Copy link

codecov bot commented Oct 18, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.

Files with missing lines Coverage Δ
src/optimagic/visualization/backends.py 98.79% <100.00%> (+1.12%) ⬆️
src/optimagic/visualization/convergence_plot.py 95.45% <100.00%> (+6.92%) ⬆️
src/optimagic/visualization/profile_plot.py 91.52% <ø> (+0.61%) ⬆️

... and 1 file with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@review-notebook-app
Copy link

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

@r3kste r3kste requested a review from timmens October 18, 2025 12:34
Copy link
Member

@timmens timmens left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very nice changes, thanks a lot.

@r3kste r3kste requested a review from timmens October 19, 2025 08:32
Copy link
Member

@timmens timmens left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very nice, thank you.

I have two tiny documentation comments. Additionally, after looking at the matplotlib gridplot, I've realized that the plotly gridplot does not have sufficient horizontal padding between the plots.

  1. Can you adjust the horizontal padding of the plotly gridplots such that they look good (similar to the matplotlib figures)
  2. Can you quickly check whether you can adjust the plotly figure sizes so that they look good in the optimagic docs? When going through the how-to guide where the convergence plot is shown, it seems like the figure goes over the page margin. But that might only be my laptop screen, if you cannot detect an issue there just ignore it.

Thanks a lot!

@r3kste
Copy link
Collaborator Author

r3kste commented Oct 20, 2025

When going through the how-to guide where the convergence plot is shown, it seems like the figure goes over the page margin.

It occurs on my environment too. Moreover, it seems like it has been this way previously as well.

One solution is to update the dimensions from 320x1000 to 320x840, so as to fit the figure within the margins. However, I also noticed that the dataframes being displayed in Convergence report also goes over the page margin.

So, I believe the ideal way to fix this issue for both cases would be to enable scrolling using myst-nb's nb_scroll_outputs option.

diff --git a/docs/source/conf.py b/docs/source/conf.py
index 89f9104..8c77a28 100644
--- a/docs/source/conf.py
+++ b/docs/source/conf.py
@@ -173,6 +173,7 @@ else:
 nb_execution_mode = "force"  # "off", "force", "cache", "auto"
 nb_execution_allow_errors = False
 nb_merge_streams = True
+nb_scroll_outputs = True

 # Notebook cell execution timeout; defaults to 30.
 nb_execution_timeout = 1000

I would like to know your thoughts on this. Thanks!
Unrelated, but it looks like alternate rows in the displayed dataframe are not properly visible in dark mode.

@timmens
Copy link
Member

timmens commented Oct 20, 2025

Thanks! I like your proposal as a quick fix! We can keep it like that here.

However, I think for most figures / dataframe representations we actually do not want scrolling. Can you open an enhancement issue for the docs, saying that you did this change here but that, as discussed with me, we rather want to update the docs such that the margins are respected?

@r3kste r3kste merged commit 9976689 into optimagic-dev:main Oct 20, 2025
26 checks passed
@r3kste
Copy link
Collaborator Author

r3kste commented Oct 31, 2025

Previously, create_grid_plot accepted a few additional parameters that were not used by convergence_plot, including:

  • scientific_notation
  • share_xax
  • x_min
  • x_max

Accordingly, the new implementation in backends.py follows the default behavior associated with their default argument values.

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.

2 participants