From e511f4b787a3b692eafb9c3f9b8cf88ba83bad4d Mon Sep 17 00:00:00 2001 From: Tim Treis Date: Fri, 30 Aug 2024 10:17:21 -0400 Subject: [PATCH] hotfix --- src/spatialdata_plot/pl/utils.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/spatialdata_plot/pl/utils.py b/src/spatialdata_plot/pl/utils.py index 4851d0ff..333809ce 100644 --- a/src/spatialdata_plot/pl/utils.py +++ b/src/spatialdata_plot/pl/utils.py @@ -877,7 +877,14 @@ def _generate_base_categorial_color_mapping( if "#" not in na_color: # should be unreachable, but just for safety raise ValueError("Expected `na_color` to be a hex color, but got a non-hex color.") - return dict(zip(categories, colors + [na_color])) + + colors = [to_hex(to_rgba(color)[:3]) for color in colors] + na_color = to_hex(to_rgba(na_color)[:3]) + + if na_color and len(categories) > len(colors): + return dict(zip(categories, colors + [na_color])) + + return dict(zip(categories, colors)) return _get_default_categorial_color_mapping(color_source_vector)