Skip to content

Commit 53dd92e

Browse files
committed
Remove color if no table
1 parent 3ca0a91 commit 53dd92e

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

src/spatialdata_plot/pl/utils.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1350,12 +1350,15 @@ def _update_element_table_mapping_label_colors(
13501350
render_elements
13511351
), "Either one color should be given or the length should be equal to the number of elements being plotted."
13521352
for index, element_name in enumerate(render_elements):
1353-
for table_name in element_table_mapping[element_name].copy():
1354-
if (
1355-
params.color[index] not in sdata[table_name].obs.columns
1356-
and params.color[index] not in sdata[table_name].var_names
1357-
):
1358-
element_table_mapping[element_name].remove(table_name)
1353+
if len(element_table_mapping[element_name]) !=0:
1354+
for table_name in element_table_mapping[element_name].copy():
1355+
if (
1356+
params.color[index] not in sdata[table_name].obs.columns
1357+
and params.color[index] not in sdata[table_name].var_names
1358+
):
1359+
element_table_mapping[element_name].remove(table_name)
1360+
else:
1361+
params.color[index] = None
13591362

13601363
# We only want one table containing the color column per element
13611364
for element_name, table_set in element_table_mapping.items():

0 commit comments

Comments
 (0)