Skip to content

Commit ba5a5eb

Browse files
committed
refactor(render): thread color_spec through _render_points mutation pipeline (#700)
1 parent b9ba6d5 commit ba5a5eb

1 file changed

Lines changed: 11 additions & 7 deletions

File tree

src/spatialdata_plot/pl/render.py

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1465,7 +1465,6 @@ def _render_points(
14651465
preloaded_color_data=_preloaded,
14661466
)
14671467
colortype = color_spec.colortype
1468-
color_source_vector, color_vector = color_spec.source_vector, color_spec.color_vector
14691468

14701469
if added_color_from_table and col_for_color is not None:
14711470
_reparse_points(
@@ -1477,15 +1476,18 @@ def _render_points(
14771476
col_for_color,
14781477
)
14791478

1480-
_warn_groups(groups, colortype, color_source_vector, col_for_color)
1479+
_warn_groups(groups, colortype, color_spec.source_vector, col_for_color)
14811480

14821481
# When groups are specified, filter out non-matching elements by default.
14831482
# Only show non-matching elements if the user explicitly sets na_color.
14841483
_na = render_params.cmap_params.na_color
1485-
if groups is not None and color_source_vector is not None and (_na.default_color_set or _na.is_fully_transparent()):
1486-
keep, color_source_vector, color_vector = _filter_groups_transparent_na(
1487-
groups, color_source_vector, color_vector
1488-
)
1484+
if (
1485+
groups is not None
1486+
and color_spec.source_vector is not None
1487+
and (_na.default_color_set or _na.is_fully_transparent())
1488+
):
1489+
keep = color_spec.source_vector.isin(groups)
1490+
color_spec = color_spec.filter(keep)
14891491
n_points = int(keep.sum())
14901492
if n_points == 0:
14911493
return
@@ -1494,7 +1496,9 @@ def _render_points(
14941496
adata = adata[keep]
14951497
_reparse_points(sdata_filt, element, points, transformation_in_cs, coordinate_system, col_for_color)
14961498

1497-
color_vector = _maybe_apply_transfunc(colortype, color_vector, render_params.transfunc)
1499+
# carrier pipeline done; unpack the final vectors for the read/draw phase below
1500+
color_spec = color_spec.apply_transfunc(render_params.transfunc)
1501+
color_source_vector, color_vector = color_spec.source_vector, color_spec.color_vector
14981502

14991503
trans, trans_data = _prepare_transformation(sdata.points[element], coordinate_system, ax)
15001504

0 commit comments

Comments
 (0)