Skip to content

Combined slider for slicer plots#538

Merged
nvaytet merged 34 commits intomainfrom
combined-slider
Mar 5, 2026
Merged

Combined slider for slicer plots#538
nvaytet merged 34 commits intomainfrom
combined-slider

Conversation

@nvaytet
Copy link
Member

@nvaytet nvaytet commented Mar 4, 2026

This adds a new slider for the slicer plot which combines a range slider (two handles) and a single slider (one handle) where the mode can be toggled with a button click.

It also adds text fields instead of a read-only text as readouts, which enables the user to enter the values they want.
If the requested value is outside the range, it will clamp to the bounds of the axes.
If the requested value does not match an exact coordinate value it will snap to the closest value available.

The combined slider is now enabled by default in the slicer plot.

Example:

%matplotlib widget
import plopp as pp
from plopp.data.examples import clusters3d

da = clusters3d(nclusters=50, seed=12).hist(z=100, y=100, x=100)
pp.slicer(da, keep=['x', 'y'], logc=True, mode="combined")
Screenshot_20260304_142635

The text boxes also properly handle bin edges and datetime coords (this is why the changes here got quite complicated).

Copy link
Contributor

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

This PR adds a new "combined" slider mode to the slicer plot that allows users to toggle between a range slider (two handles) and a single-handle slider within the same widget. It also replaces the read-only label readouts with editable text fields, enabling users to type exact coordinate values directly. The combined mode is enabled by default.

Changes:

  • Replaces slice.py with slicing.py, introducing CombinedSliceWidget, BoundedText, BoundedBinEdgeText, and related bounded-text readout widgets
  • Extends Slicer and slicer() to support mode ('single', 'range', 'combined') and operation parameters; adds _maybe_reduce_dim for reducing sliced dims; the figure now uses reduce_nodes instead of slice_nodes
  • Expands the test suite with parametrized tests for all three modes, including datetime and bin-edge coordinate cases

Reviewed changes

Copilot reviewed 9 out of 10 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/plopp/widgets/slicing.py New widget file implementing bounded text readouts and combined slider
src/plopp/widgets/__init__.pyi Exports CombinedSliceWidget from the new module
src/plopp/plotting/slicer.py Adds mode/operation params, _maybe_reduce_dim, switches figure to reduce_nodes
src/plopp/plotting/superplot.py Explicitly sets mode='single' for superplot
tests/widgets/slice_test.py Updated/extended tests for new bounded text readouts
tests/plotting/slicer_test.py New parametrized tests for all three slider modes
docs/plotting/slicer-plot.ipynb Updated example notebook to use new combined default and mode='single' for player
docs/getting-started/numpy-pandas-xarray.ipynb Minor datetime formatting note added
docs/_static/plotting/slicer-plot.png Updated screenshot

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

@nvaytet nvaytet merged commit 788e1dd into main Mar 5, 2026
4 checks passed
@nvaytet nvaytet deleted the combined-slider branch March 5, 2026 14:24
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.

3 participants