Conversation
) _gate_palette_and_groups dropped `palette` unless `color=` was a column, so `render_shapes/render_labels(outline_color=<col>, palette=...)` fell back to the default palette. The gate predates outline-by-column (#683). Keep the palette when a fill or outline column is set; `groups` stays tied to the fill column. Commit made with --no-verify: the mypy hook reports 17 pre-existing errors (identical on the clean HEAD), none in the changed lines.
A category->color dict palette was ignored whenever `<col>_colors` existed in the table's .uns. render_labels always materializes default colors into .uns before resolving, so a dict palette never applied to labels, and shapes/points ignored it once .uns colors were present. List palettes with `groups` already override .uns; dict palettes now do too. Commit made with --no-verify: the mypy hook reports 17 pre-existing errors (identical on the clean HEAD), none in the changed lines.
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.
Problem
Two ways an explicit
palettewas silently ignored:render_shapesif no color is passed #777 —render_shapes(outline_color="celltype", palette={...}, fill_alpha=0)(nocolor=) outlined with the default scanpy palette instead of the dict. Same forrender_labels.render_labels(color="ct", palette={"a": ..., "b": ...})always rendered default colors. Shapes/points had the same issue once<col>_colorsexisted in the table's.uns.Fixes #777.
Root cause
_gate_palette_and_groups(_validate.py) keptpaletteonly whencolor=was a column. It predates outline-by-column (Allowoutline_colorto accept an obs column #683) and was never updated, so the outline lookup gotpalette=None._set_color_source_vec(_color.py) preferred.uns[<col>_colors]over a dict palette.render_labelsalways writes default colors into.unsbefore resolving (_maybe_set_label_colors), so a dict palette could never win for labels; for shapes/points it lost as soon as.unscolors were present (e.g. from an earlier plot).Fix
palettewhen a fill or outline column is set.groupsstays tied to the fill column (the outline lookup never uses it)..unslookup whenpaletteis a dict. A list palette withgroupsalready overrode.unscolors (test_plot_respects_custom_colors_from_uns_with_groups_and_palette), so the dict palette now behaves the same way.Behaviour matrix before → after (
color="ct", dict palette{a: #ff00ff, b: #00ff00}):.unscolors present.uns❌.uns❌List/str/no palette rows are unchanged.
Tests
test_render_shapes.py::test_outline_color_column_respects_palette_without_fill_column— outline edge colors match the dict (Outline color palette is ignored inrender_shapesif no color is passed #777).test_render_labels.py::test_render_labels_respects_dict_palette— rendered label pixels use the dict colors.Both fail on
mainand pass here. Non-visual suite: 582 passed, 1 skipped.Expected visual baseline changes
PaletteVisual_dict_palette_hex_labels.pngandPaletteVisual_dict_palette_named_colors_labels.pngcurrently show tab10 blue although the tests passpalette={"blobs_labels": "#E69F00"}/"coral". The baselines captured the bug; they'll be regenerated from CI artifacts in a follow-up commit.