fix(labels): separate per-render categorical legends with distinct palettes#723
Open
timtreis wants to merge 1 commit into
Open
fix(labels): separate per-render categorical legends with distinct palettes#723timtreis wants to merge 1 commit into
timtreis wants to merge 1 commit into
Conversation
9b0fe30 to
132b23f
Compare
…lettes (#364) Stacking multiple categorical `render_labels` calls produced a single merged legend (scanpy's bare `ax.legend()` auto-collected every labeled artist and dropped the previous legend) and reused the same default palette, so the overlaid layers were indistinguishable. - Each categorical render now gets its own legend; 2nd+ legends are built with explicit handles and laid out left-to-right along the top margin in a post-render pass (`_layout_panel_legends_rightward`), robust to tall legends and `constrained_layout` reflow. Only legends this code owns (tagged `_sdata_column`) are touched, so fill/outline and channel legends keep their placement. - Later categorical label renders offset into the palette to skip colors already used on the panel (`_next_palette_colors`), keeping layers distinct. - A legend is titled by its column only when 2+ legends share an axis (to tell them apart); a lone legend stays untitled. - Shared helpers `_legend_ncol`, `_categorical_legend_handles`, and `_default_categorical_palette` remove duplicated logic. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.
Fixes #364.
Stacking categorical
render_labelscalls gave one merged legend (scanpy's bareax.legend()collected every artist and dropped the prior legend) with reused colors._sdata_column, so fill/outline & channel legends are untouched).