Summary
Improve the visual representation of Regions of Interest (ROIs) on signals so that several ROIs displayed on the same curve are clearly distinguishable, and so that the highlighted area follows the signal curve instead of filling the whole canvas height.
Motivation
The current Signal ROI representation has two limitations that hurt readability when multiple ROIs are defined on the same signal:
- Single fill color: every ROI uses the same translucent yellow rectangle. When several ROIs are defined on the same signal, it is hard to tell them apart at a glance.
- Full-height rectangle: the fill spans the entire canvas height, visually obscuring nearby curves and disconnecting the highlighted area from the actual signal it refers to.
This is particularly noticeable in spectral analysis use cases where many narrow ROIs are placed side by side along a curve (e.g. energy windows on a gamma spectrum).
Proposed change
Update datalab.adapters_plotpy.roi.signal so that:
- The translucent ROI fill is clipped vertically to the signal curve (polygon following
(x, y(x)) between xmin and xmax), with a flat baseline at y = 0 (clamped to the visible canvas; falls back to the canvas bottom on a logarithmic Y axis where y = 0 is undefined).
- Each ROI is drawn with a different color, picked from a small cyclic palette (10 colors, matplotlib
tab10-inspired). The color is derived from the ROI<n> title index, so a given ROI keeps the same color across deletions, reorderings, panel refreshes and editor reopenings.
- The selection visual (different pen on the active ROI) is preserved.
- Non-finite samples (
NaN/Inf) in the signal are filtered out before computing the polygon, so signals with gaps render cleanly.
The change is GUI-only and non-breaking:
- ROI persistence (HDF5/JSON) is unchanged: only coordinates are stored; visual properties are recomputed when ROIs are rendered.
- The public API of
SegmentROIPlotPyAdapter / SignalROIPlotPyAdapter is preserved; a new optional fill_color keyword is added to to_plot_item().
- A new public helper
roi_color_for_index(index) is exposed for callers that need to align UI elements (legend, table, etc.) with ROI colors.
Before / After
|
Before |
After |
| Fill |
Single yellow translucent rectangle, full canvas height |
Polygon clipped to the signal curve, baseline at y = 0 |
| Multiple ROIs |
All identical |
Cyclic 10-color palette, stable per ROI |
| Log Y |
Same |
Baseline gracefully falls back to canvas bottom |
| NaN/Inf in data |
Could produce artifacts |
Filtered out before drawing |
Summary
Improve the visual representation of Regions of Interest (ROIs) on signals so that several ROIs displayed on the same curve are clearly distinguishable, and so that the highlighted area follows the signal curve instead of filling the whole canvas height.
Motivation
The current Signal ROI representation has two limitations that hurt readability when multiple ROIs are defined on the same signal:
This is particularly noticeable in spectral analysis use cases where many narrow ROIs are placed side by side along a curve (e.g. energy windows on a gamma spectrum).
Proposed change
Update
datalab.adapters_plotpy.roi.signalso that:(x, y(x))betweenxminandxmax), with a flat baseline aty = 0(clamped to the visible canvas; falls back to the canvas bottom on a logarithmic Y axis wherey = 0is undefined).tab10-inspired). The color is derived from theROI<n>title index, so a given ROI keeps the same color across deletions, reorderings, panel refreshes and editor reopenings.NaN/Inf) in the signal are filtered out before computing the polygon, so signals with gaps render cleanly.The change is GUI-only and non-breaking:
SegmentROIPlotPyAdapter/SignalROIPlotPyAdapteris preserved; a new optionalfill_colorkeyword is added toto_plot_item().roi_color_for_index(index)is exposed for callers that need to align UI elements (legend, table, etc.) with ROI colors.Before / After
y = 0