Skip to content

Commit cfcc3fe

Browse files
committed
Improve sparse datapoint plotting in pyqtgraph and fastplotlib
1 parent c4c9791 commit cfcc3fe

4 files changed

Lines changed: 277 additions & 135 deletions

File tree

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -159,19 +159,19 @@ The following libraries are used:
159159
- [PyQt5 or 6 - UI](https://www.riverbankcomputing.com/software/pyqt/)
160160
- [pyqtgraph - charting](https://www.pyqtgraph.org/)
161161
- [re - regular expression filter](https://docs.python.org/3/library/re.html)
162-
- [scipy - fft](https://scipy.org/) `***`
162+
- [scipy - fft](https://scipy.org/) `****`
163163
- [setuptools](https://github.com/pypa/setuptools)`*`
164-
- [tamp - compressor](https://github.com/BrianPugh/tamp) `***`
164+
- [tamp - compressor](https://github.com/BrianPugh/tamp) `****`
165165
- [textwrap - logging](https://docs.python.org/3/library/textwrap.html)
166166
- [time](https://docs.python.org/3/library/time.html)
167167
- [typing](https://docs.python.org/3/library/typing.html)
168168
- [wmi - USB events](https://timgolden.me.uk/python/wmi/index.html) or [pyudev - USB events](https://pyudev.readthedocs.io/en/latest/)
169-
- [zlib - compressor](https://docs.python.org/3/library/zlib.html) `***`
169+
- [zlib - compressor](https://docs.python.org/3/library/zlib.html) `****`
170170

171171
[`*`] not required but will accelerate the program,
172172
[`**`] needed if BLE is enabled,
173173
[`***`] needed if fastplotlib is enabled,
174-
[`***`] future version
174+
[`****`] future version
175175

176176
## Scripts
177177

ToDo.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,3 +100,22 @@ When the operating system is using a dark theme, parts of the SerialUI interface
100100
- `with_alpha`
101101
- `blend_colors`
102102
- `build_chart_theme`
103+
104+
## Plotting of isolated values
105+
When occasional values are received interspersed with frequent values from another measurement, the parser and ring buffer correctly keep all channels on the same sample timeline and leave missing entries as `NaN`. This preserves alignment between slow and fast measurements, but sparse channels then appear as isolated finite values surrounded by `NaN`. In pyqtgraph, those `NaN` values break line segments. In fastplotlib, the current compaction of finite values risks connecting points across time gaps. We need a plotting approach that displays sparse event-like values together with dense continuous signals while keeping plotting fast and efficient.
106+
107+
[Status: implemented for pyqtgraph and fastplotlib automatic mode]
108+
[Plan:
109+
- Keep the current parser and circular buffer structure unchanged so all channels remain aligned on the same sample-number axis and sparse channels continue to be represented by `NaN` gaps.
110+
- Add a plotting-level render mode concept for traces, with at least `line`, `scatter`, and `hybrid` behavior.
111+
- Use `auto` as the default engagement mode and do not add new main-window controls in the first implementation.
112+
- In `auto`, classify each visible trace from the current data pattern and choose between line-only, scatter-only, or hybrid behavior.
113+
- Keep the first rollout UI-free. If manual override is needed later, add it as a context-menu action on the plot or legend rather than consuming permanent screen space.
114+
- In pyqtgraph, keep the existing line trace with `connect='finite'` for continuous data and add a scatter overlay for isolated points detected from the visible `NaN` pattern. Done.
115+
- Detect isolated values efficiently per channel using finite-neighbor checks, for example a point that is finite while both the previous and next samples are non-finite.
116+
- Keep pyqtgraph legend and visibility behavior tied to the main line item while the scatter overlay remains an internal helper trace. Done.
117+
- In fastplotlib, stop treating all finite values as a single compacted line when that would bridge time gaps. Preserve segment breaks by inserting separator rows for discontinuities and render isolated samples with a native scatter overlay. Done.
118+
- Add a simple heuristic or per-channel mode selection so dense channels remain line plots while sparse channels can automatically switch to scatter or hybrid display.
119+
- In fastplotlib, rebuild the visible trace buffer from the current window so line continuity follows the original sample timeline instead of the old compacted append-only representation. Done.
120+
- Keep autoscaling and legend behavior consistent across both backends, including visibility toggles and efficient min/max computation for sparse channels.
121+
- Implement the pyqtgraph version first because it already preserves `NaN` segment breaks cleanly, then bring fastplotlib to feature parity with the same visual behavior.]

config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from helpers.colors import color_names_sweet16 as COLORS
77
################################################################################################################################
88
# Constants General
9-
VERSION = "1.5.2" # this version
9+
VERSION = "1.5.3" # this version
1010
AUTHOR = "Urs Utzinger" # me
1111
DATE = "2026" # year of last update
1212
################################################################################################################################

0 commit comments

Comments
 (0)