Skip to content

Fix double artist registration in render_labels and render_points#634

Merged
timtreis merged 3 commits intomainfrom
fix/issue-594-double-add-artist
Apr 24, 2026
Merged

Fix double artist registration in render_labels and render_points#634
timtreis merged 3 commits intomainfrom
fix/issue-594-double-add-artist

Conversation

@timtreis
Copy link
Copy Markdown
Member

@timtreis timtreis commented Apr 24, 2026

Summary

  • ax.imshow() and ax.scatter() already register the returned artist in ax.images / ax.collections internally. The subsequent ax.add_image() / ax.add_collection() calls inserted a second reference to the same object, so matplotlib composited the layer twice.
  • At fill_alpha=0.4 this produced effective opacity 1-(1-0.4)^2 = 0.64 instead of 0.4. The default labels alpha of 0.4 was effectively 0.64 on every plot.
  • Fix: drop the two redundant calls and return the artist directly. Two one-line changes; no API impact.

Closes #594

timtreis and others added 3 commits April 24, 2026 15:01
ax.imshow and ax.scatter already register the returned artist in
ax.images / ax.collections internally. The subsequent ax.add_image /
ax.add_collection calls inserted a second reference to the same object,
causing the layer to be composited twice and making effective alpha
1-(1-alpha)^2 instead of alpha.

Fix: drop the redundant add_image / add_collection calls and return the
artist directly.

Closes #594
…date reference images

The _cax intermediate was introduced alongside the now-removed
ax.add_image / ax.add_collection calls. With those calls gone, the
variable serves no purpose -- rename directly to cax at the scatter /
imshow call site.

Reference images for visual tests regenerated from CI artifacts to
reflect the corrected single-compositing alpha output.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@codecov-commenter
Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 76.32%. Comparing base (18adeb9) to head (874b5e8).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #634      +/-   ##
==========================================
- Coverage   76.33%   76.32%   -0.02%     
==========================================
  Files          11       11              
  Lines        3229     3227       -2     
  Branches      757      757              
==========================================
- Hits         2465     2463       -2     
  Misses        465      465              
  Partials      299      299              
Files with missing lines Coverage Δ
src/spatialdata_plot/pl/render.py 86.14% <100.00%> (-0.05%) ⬇️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@timtreis timtreis merged commit 525c94a into main Apr 24, 2026
8 checks passed
@timtreis timtreis deleted the fix/issue-594-double-add-artist branch April 24, 2026 13:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

render_labels and render_points register the same artist twice, inflating effective alpha

2 participants