Skip to content

Commit 629f86c

Browse files
committed
legend ordering now deterministic again
1 parent 7b1adfd commit 629f86c

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

src/spatialdata_plot/pl/utils.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1109,6 +1109,9 @@ def _set_color_source_vec(
11091109
return None, numeric_vector, False
11101110

11111111
assert isinstance(processed, pd.Categorical)
1112+
if not processed.ordered:
1113+
# ensure deterministic category order when the source is unordered (e.g., from a Python set)
1114+
processed = processed.reorder_categories(sorted(processed.categories))
11121115
color_source_vector = processed # convert, e.g., `pd.Series`
11131116

11141117
# Use the provided table_name parameter, fall back to only one present

0 commit comments

Comments
 (0)