Skip to content

feat(show): add xlabel/ylabel to control panel axis labels - #766

Merged
timtreis merged 4 commits into
mainfrom
fix/issue-763
Aug 12, 2026
Merged

feat(show): add xlabel/ylabel to control panel axis labels#766
timtreis merged 4 commits into
mainfrom
fix/issue-763

Conversation

@timtreis

@timtreis timtreis commented Aug 12, 2026

Copy link
Copy Markdown
Member

Closes #763.

Adds show(xlabel=..., ylabel=...) to set the x/y axis labels on every rendered panel. Previously callers (squidpy's spatial_scatter/spatial_segment) had to reach into the returned axes and call set_xlabel/set_ylabel per panel.

sdata.pl.render_images("he").pl.show(xlabel="x (µm)", ylabel="y (µm)")
sdata.pl.render_images("he").pl.show(xlabel="µm", ylabel="µm")  # same unit on both
  • Each is str | None; None (default) leaves that axis unlabelled (current behavior).
  • Applied in _finalize_panel next to the existing set_title, so they broadcast to all panels and work with user-supplied axes.

Named xlabel/ylabel to match matplotlib rather than squidpy's axis_label: squidpy's variant is an overloaded str | Sequence whose str case adds numeric suffixes and whose default draws labels, so matching only the name would inherit a union type while behaving differently. Two plain string params keep the interface unambiguous and one-thing-per-param.

Tests

tests/pl/test_show.py: labels set per axis, one-axis-only, empty by default, broadcast across a multi-panel plot; validation rejects non-str inputs.

Adds show(axis_label=...) to set x/y axis labels on every rendered panel,
mirroring squidpy's spatial_scatter kwarg. Accepts a single string (both
axes) or an (x, y) pair; None keeps the current unlabelled behavior.

Closes #763
Replaces the overloaded axis_label (str | pair) with separate xlabel/ylabel
str params, matching matplotlib's set_xlabel/set_ylabel. squidpy's axis_label
carries different semantics (numeric suffixes, default-on), so matching its
name without its behavior added a union type for no interop benefit.
@timtreis timtreis changed the title feat(show): add axis_label to control panel axis labels feat(show): add xlabel/ylabel to control panel axis labels Aug 12, 2026
@codecov-commenter

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 79.66%. Comparing base (f0482e9) to head (78be306).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #766      +/-   ##
==========================================
+ Coverage   79.63%   79.66%   +0.03%     
==========================================
  Files          18       18              
  Lines        4665     4672       +7     
  Branches     1032     1036       +4     
==========================================
+ Hits         3715     3722       +7     
  Misses        599      599              
  Partials      351      351              
Files with missing lines Coverage Δ
src/spatialdata_plot/pl/_validate.py 70.78% <100.00%> (+0.11%) ⬆️
src/spatialdata_plot/pl/basic.py 83.00% <100.00%> (+0.14%) ⬆️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@timtreis
timtreis merged commit fbb6872 into main Aug 12, 2026
8 checks passed
@timtreis
timtreis deleted the fix/issue-763 branch August 12, 2026 15:52
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.

Expose axis label control on show()

2 participants