Skip to content

Commit ffd4a1f

Browse files
authored
hotfix (#341)
1 parent 1bd4b78 commit ffd4a1f

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/spatialdata_plot/pl/utils.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -877,7 +877,14 @@ def _generate_base_categorial_color_mapping(
877877
if "#" not in na_color:
878878
# should be unreachable, but just for safety
879879
raise ValueError("Expected `na_color` to be a hex color, but got a non-hex color.")
880-
return dict(zip(categories, colors + [na_color]))
880+
881+
colors = [to_hex(to_rgba(color)[:3]) for color in colors]
882+
na_color = to_hex(to_rgba(na_color)[:3])
883+
884+
if na_color and len(categories) > len(colors):
885+
return dict(zip(categories, colors + [na_color]))
886+
887+
return dict(zip(categories, colors))
881888

882889
return _get_default_categorial_color_mapping(color_source_vector)
883890

0 commit comments

Comments
 (0)