Feature/outline color for labels#525
Conversation
|
@timtreis Naive question but I can't find where to download the artifacts to fix the tests, is this a permission issue or am I missing something? |
|
@MeyerBender artifacts can be downloaded from the Actions page, for instance here: https://github.com/scverse/spatialdata-plot/actions/runs/20439596502?pr=526 Please find more info here: https://github.com/scverse/spatialdata-plot/blob/main/docs/contributing.md. Let me know if some questions are still open and not covered by the contribution guide. |
|
Thanks @LucaMarconato! With my current implementation, it is only possible to specify a colorlike, but not a feature (like "area"). I think it would be good to merge #497 first, and then add my code on top of that. |
for more information, see https://pre-commit.ci
- Simplify outline_color type for labels to ColorLike | None (no tuple) - Store as Color | None in LabelsRenderParams (consistent with shapes) - Add proper type annotation to _draw_labels - Simplify _map_color_seg boundary rendering: build clean RGBA image with outline_color on the eroded ring, transparent elsewhere - Remove duplicate matplotlib.colors import (mcolors → colors) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Move the label2rgb call below the seg_boundaries early return so it is not computed when only the outline ring is needed. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
7d8202e to
3e2d6a1
Compare
Add baselines for new outline_color tests and update existing baselines that changed due to the find_boundaries → solid outline_color rewrite and square → footprint_rectangle migration. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #525 +/- ##
==========================================
+ Coverage 73.66% 73.83% +0.16%
==========================================
Files 10 10
Lines 2738 2748 +10
Branches 637 638 +1
==========================================
+ Hits 2017 2029 +12
+ Misses 447 446 -1
+ Partials 274 273 -1
🚀 New features to boost your workflow:
|
…or is None Only apply uniform outline_color when explicitly set. When None (default), use the data-driven colors from label2rgb on the eroded ring — preserving the existing behavior for continuous/categorical outline coloring. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
When color is a literal (e.g., 'white') and no outline_color is given, use the literal color for outlines. This fixes the invisible-outline case from issue scverse#462 where color='white' with outline_alpha=1 produced white outlines on a white background because the data-driven path was used instead. When color is a column name (data-driven), outlines still inherit per-label colors from the colormap. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Use contour_px=10 for thicker outlines and blue instead of white for the fill+outline test so the outline is clearly distinguishable in baseline images. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
Hey @MeyerBender, I merged #497 and updated your PR accordingly. Could you verify that it matches the behaviour you intended? |
|
Hi @timtreis, this looks great, thanks a lot! As a sidenote, running |
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Correct docstring: outline_color=None inherits from literal color or uses data-driven per-label colors (not "black") - Add test for literal color inheritance (scverse#462 scenario) - Add test for data-driven outline colors Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This addresses two previous issues with rendering labels:
outline_colorargument, similar to how they could inrender_shapes(), see Ability to change color of the border of labels #462render_labels, see Color leak whenoutline_alpha=1andfull_alpha=0#461Example code to see both changes in action: