Skip to content

Add interactive fitting example#5

Merged
CSSFrancis merged 6 commits intomainfrom
add-interactive-fitting-example
Apr 6, 2026
Merged

Add interactive fitting example#5
CSSFrancis merged 6 commits intomainfrom
add-interactive-fitting-example

Conversation

@CSSFrancis
Copy link
Copy Markdown
Owner

Kind of a fun one. But I added in an example of fitting using mutiple components.

Screen.Recording.2026-04-05.at.10.12.52.PM.mov

@ericpre you might like this.

@CSSFrancis
Copy link
Copy Markdown
Owner Author

I just added an event where "f" fits the data using scipy.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds a new interactive 1‑D Gaussian fitting example and extends the widget/line interaction system to support richer interactions (widget visibility, new widget styles, and improved line hover/click behavior).

Changes:

  • Add Widget.show()/hide() + visible state, and make JS rendering/hit-testing respect hidden widgets.
  • Extend 1‑D widgets: RangeWidget(style='band'|'fwhm', y=...) and PointWidget(show_crosshair=...); add Line1D.set_data() for live overlay updates.
  • Add a new interactive fitting example and a large set of tests covering line click routing and widget visibility/fitting flows.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
tests/test_widgets.py Adds new line-click tests and extensive new widget visibility + interactive fitting scenario tests.
pyproject.toml Adds SciPy to optional dependencies (docs extra).
Examples/Interactive/plot_interactive_fitting.py New end-to-end interactive Gaussian fitting example using widgets + SciPy fitting.
anyplotlib/widgets.py Implements widget visibility API and extends RangeWidget/PointWidget initialization options.
anyplotlib/figure_plots.py Adds Line1D.set_data() and extends widget-creation APIs with new parameters and optional batching.
anyplotlib/figure_esm.js Implements visibility filtering, new widget rendering modes, improved line hover highlighting, and adjusted click/drag logic.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@CSSFrancis
Copy link
Copy Markdown
Owner Author

I also added in the ability to add a ? help tool tip.

This is something I've always wanted in HyperSpy. So often I think the interactive features are hidden and a little help section would be so nice.

@CSSFrancis CSSFrancis merged commit 7f11f7c into main Apr 6, 2026
11 checks passed
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