Skip to content

A bunch of long overdue updates to the plotting system#72

Open
allevitan wants to merge 23 commits intomasterfrom
feature/betterplots
Open

A bunch of long overdue updates to the plotting system#72
allevitan wants to merge 23 commits intomasterfrom
feature/betterplots

Conversation

@allevitan
Copy link
Collaborator

@allevitan allevitan commented Mar 21, 2026

Changes

  • Added the ability for CDIModels to define panel-style multi-figure layouts, with an automatic fallback option to single-figure layouts. This is much more manageable for e.g. live work at a beamline.
  • Switched to a dictionary-based definition for registered plots, as the old system was quite hard to read
  • Created a nice panel layouts for FancyPtycho and RPI using the new system.
  • Updated all remaining models to the new system, leaving their current plotting behavior intact.
  • Added a "plot_level" tag to each plot so users can control the level of detail in plotting. plot_level=0 turns off all plots, and larger numbers add progressively more plots.
  • Added a "min_interval" argument to model.inspect() to make it easier to plot occasionally during reconstructions.
  • Improved the handling of figures being closed during live reconstructions. Now, a closed figure will not render on subsequent calls to inspect(), improving speed. A new argument, "replot_all", can be used to force a replot at the end.
  • Tested in Jupyter and developed a workaround pattern to make it more manageable to work in a notebook environment
  • Updated example scripts to use the new features, and made minor changes to improve useability of the scripts on devices without CUDA.

Remaining Todos

  • Update image stack plotting with a slider instead of current ad-hoc system
  • Update documentation with new plotting approach
  • Identify key tests which need to be added to test the system
  • Final re-check of the example scripts

allevitan and others added 23 commits March 20, 2026 09:47
- Switch panel plots to use subfigures with constrained_layout for better layout management
- Add plot_loss_history method to CDIModel base class
- Fix matplotlib compatibility for older versions (interactive backend detection)
- Make CUDA usage conditional in examples
- Add panel_plot_mode and plot_level params to FancyPtycho constructor
- Default plot_level filtering to 1 instead of 0

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Add title parameter to plot_image, plot_real, plot_imag, plot_amplitude,
  plot_phase, and plot_colorized
- Various fixes to base.py and fancy_ptycho.py

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…t easier to not plot so much without manual intervention
…mapping and a colorbar for accurate reading of phases
… be useful for publishing figures now that it's not just a simple hsv lookup. Also fix a bug with nonresponsive windows when all model plots are closed, but the dataset plots are still showing.
…d_layout, which was causing hangups during live plotting and didn't look as nice
All public functions in plotting.py now use the expanded multi-line
signature format with trailing commas for consistency and readability.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…ap_with_images

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…or un-exponentiated objects, and also update test_fancy_ptycho to show all the plots (not just plot level 2)
@allevitan allevitan marked this pull request as ready for review March 24, 2026 20:56
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