Support Arduino-style labeled multi-value plotter data#487
Open
makermelissa-piclaw wants to merge 2 commits intocircuitpython:betafrom
Open
Conversation
Match the Arduino IDE Serial Plotter input format so sketches that print 'label:value' pairs separated by tabs (or commas/spaces) are plotted with the labels shown in the legend instead of confusing the parser. Each labeled series is tracked by name across frames so the order can vary, and a per-frame padding pass keeps the x-axis aligned when not every series reports on every line. Existing tuple, list, and plain CSV formats continue to work unchanged. The default color palette is also expanded from 3 colors to 16 so plots with many series remain legible. Fixes circuitpython#457
- Drop pale tints, gray, and brown from palette since they wash out on the dark theme's #777 plotter background. - Pull legend label color from --terminal-text-color so it contrasts with the active theme instead of being hardcoded black.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #457.
The Arduino IDE Serial Plotter accepts a
label:valueformat withtab/comma/space separators (and supports many series at once). The
web-editor plotter previously only understood plain CSV / tuple /
list lines, so a sketch that prints
Temp:23.4\tHum:55.1wouldeither drop the line or only plot the digits it could pull from the
front of the token.
This PR teaches
plotValuesthe labeled format:parseLabeledValueshelper splits on,,\t, or runs ofwhitespace, then peels off an optional
label:prefix per token.stay on the same line across frames even if the sketch reorders
them (or omits some on a given frame). Unlabeled lines keep the
existing positional behavior, so old CSV / tuple / list sketches
are unaffected.
dataset is padded with
nullso the x-axis stays aligned.reused round-robin, so multi-channel sketches (e.g. the AS7343
spectral example referenced in the issue) don't all collapse to
black after the fourth series.
Manual test cases
I unit-tested the parser against the following inputs (all parse to
the expected
{label, value}pairs):1,2,31\t2\t31 2 3Temp:23.4,Hum:55.1405nm_F1:123\t425nm_F2:456\tClear:789A:1\tB:-2.5\tC:3e21,Temp:42,3(mixed labeled + positional)A:1\tB:2\t(trailing tab)Existing tuple
(1,2,3)and list[1,2,3]paths are unchanged.npm run buildpasses locally.