Skip to content

feat: add sort_order to spatial_scatter - #1291

Open
Georicl wants to merge 1 commit into
scverse:mainfrom
Georicl:feature/sort_order
Open

Georicl wants to merge 1 commit into
scverse:mainfrom
Georicl:feature/sort_order

Conversation

@Georicl

@Georicl Georicl commented Sep 14, 2026

Copy link
Copy Markdown

Description

Add sort_order=True to pl.spatial_scatter so higher continuous color values are drawn on top. Sort independently within each panel after subsetting, draw missing values first, and preserve observation order for equal values. sort_order=False retains the previous drawing order; categorical and uncolored plots retain their order.

Keep per-point collection styles aligned with the reordered coordinates, including Matplotlib aliases, cycled style sequences, scalar colors, and dash specifications. Document the new default in the API and release notes.

How has this been tested?

  • Spatial plotting tests: 133 passed, 1 skipped by the existing macOS marker.
  • New style regression tests reproduced 32 failures before the style fix; all pass after it.
  • Pixel checks cover high-expression overlap for ordinary scatter, circles, squares, and hexagons.
  • Regression coverage includes .obs, .X, layers, raw, missing and tied values, categorical colors, multiple libraries and panels, cropping, outlines, per-point styles, and patch offsets.
  • All applicable repository pre-commit checks pass.
  • Full Sphinx HTML build passes with warnings treated as errors; verified the generated scatter signature and parameter documentation, and that segmentation does not expose sort_order.

Closes

Closes #824

@codecov

codecov Bot commented Sep 15, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 96.66667% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 78.57%. Comparing base (8286274) to head (d1fae25).

Files with missing lines Patch % Lines
src/squidpy/pl/_spatial_utils.py 96.42% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1291      +/-   ##
==========================================
+ Coverage   78.44%   78.57%   +0.13%     
==========================================
  Files          63       63              
  Lines        9532     9559      +27     
  Branches     1594     1602       +8     
==========================================
+ Hits         7477     7511      +34     
+ Misses       1489     1487       -2     
+ Partials      566      561       -5     
Files with missing lines Coverage Δ
src/squidpy/pl/_spatial.py 95.23% <100.00%> (+2.38%) ⬆️
src/squidpy/pl/_spatial_utils.py 80.40% <96.42%> (+1.83%) ⬆️

... and 1 file with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

This branch has not been deployed

No deployments
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.

sort_order for pl.spatial_scatter

1 participant