score_plot: let the marker area carry a value (sizes=) - #549
Merged
Merged
Conversation
A score plot says how extreme an observation is along the components and nothing about how far it sits off them, so the reader needs a second plot for the second question. `sizes=` puts that second quantity, typically the SPE, on the marker area, and one plot answers both. Area, not diameter, is proportional to the value, and one scale is shared by the plain and the highlighted traces, so a highlighted point keeps its own area instead of being enlarged: two meanings on one channel cannot both be read. `settings["size_max"]` sets the largest marker and `size_name` names the value in the hover text, so a reader can recover it exactly. A negative value, a series that does not cover every observation, or an all-zero series raises rather than drawing a plot that cannot be read. The default path is untouched: without `sizes` the markers keep their fixed size and carry no `sizemode`. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LXthGpHLQFfGubBiKFtGAE
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
…-process-3cu4iq # Conflicts: # CHANGELOG.md # CITATION.cff # pyproject.toml
…-process-3cu4iq # Conflicts: # CHANGELOG.md # CITATION.cff # pyproject.toml
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.
Summary
score_plot(sizes=...)puts that second quantity, typically the SPE, on the marker area, and one plot answers both. It came out of the SBR batch case study, where the two faulty batches are the furthest out in the scores and carry the smallest residuals of the 53, which the sized plot shows at a glance.sizemode="area"), so a marker of twice the area stands for twice the value. Onesizerefis computed from the whole series and shared by the plain and the highlighted traces, so a highlighted point keeps its own area rather than being enlarged: two meanings on one channel cannot both be read.settings["size_max"]sets the diameter in pixels of the largest marker (default 26) andsize_namenames the value in the hover text, so the reader can recover it exactly rather than estimating an area by eye. Both the 2D and the 3D paths take it.ValueError.The parameters are keyword-only and come after
fig, so every existing positional call keeps its meaning, and withoutsizesthe markers keep their fixed size and carry nosizemode: the default path is unchanged, which a test pins.Where it is used. The SBR score plot of the book's batch case studies (kgdunn/pid-book#273, figures kgdunn/figures#91) encodes the batch's squared residual this way, with the legend giving the scale in SPE units. Until this release reaches PyPI the book draws that plot by hand in Plotly; the block collapses to one
score_plot(sizes=...)call afterwards.Test plan
uv run ruff check .anduv run ruff format --check .passuv run mypy src/process_improvepasses (163 files)uv run pytest tests/test_multivariate.py tests/test_multivariate_introspection.py: 197 passed, 1 skipped (pre-existing skip)sizemode, the per-point sizes, thesizerefarithmetic, the hover text, and one scale shared with a highlighted trace) and the settings and guards (size_max, and the three refusals)sizemode, marker size still 7maindescribed below, before pushing itChecklist
pyproject.toml(PATCH for fixes/docs/config, MINOR for new features): 1.81.1 to 1.82.0,CITATION.cffsyncedruff check .passesCHANGELOG.mdupdatedMerge of
main. #548 merged while this PR was open and took 1.81.1, which conflicted here onpyproject.toml,CITATION.cffandCHANGELOG.md. All three are metadata:maindoes not touchplots.py. Resolved by keeping 1.82.0 (a feature on top of that patch release), keeping both changelog sections with 1.82.0 above 1.81.1, and rebuilding the link footer so[1.82.0]compares againstv1.81.1.Release note.
mainis at 1.81.1 and untagged. Merging this before cutting the release makes it one release, 1.82.0, which both companion PRs can then target.🤖 Generated with Claude Code
https://claude.ai/code/session_01LXthGpHLQFfGubBiKFtGAE
Generated by Claude Code