Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/spatialdata_plot/pl/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -560,6 +560,13 @@ def _get_colors_for_categorical_obs(
else:
palette = ["grey" for _ in range(len_cat)]
logging.info("input has more than 103 categories. Uniform " "'grey' color will be used for all categories.")
else:
# raise error when user didn't provide the right number of colors in palette
if isinstance(palette, list) and len(palette) != len(categories):
raise ValueError(
f"The number of provided values in the palette ({len(palette)}) doesn't agree with the number of "
f"categories that should be colored ({categories})."
)

# otherwise, single channels turn out grey
color_idx = np.linspace(0, 1, len_cat) if len_cat > 1 else [0.7]
Expand Down