Skip to content

Commit a276bd8

Browse files
committed
Route plain density through the continuous shade path
For ``color=None``, the dispatch in ``_render_points`` was sending the aggregate to ``_ds_shade_categorical``, which uses ``color_vector[0]`` as a single hex color and only modulates alpha across counts. That collapses any sequential colormap (``viridis`` and friends) to a flat hue and makes a "density" plot look like a uniform smudge with low opacity. Plain density now routes through ``_ds_shade_continuous`` so the configured cmap is used as a real intensity gradient over the count aggregate. ``density_how`` ("linear" / "log" / "cbrt" / "eq_hist") finally produces visibly different results. The categorical density branch is unchanged: per-category color keys still pass through ``_ds_shade_categorical`` and modulate alpha per gene, which is the correct behaviour for "where does each category concentrate".
1 parent 33c84e7 commit a276bd8

4 files changed

Lines changed: 5 additions & 1 deletion

File tree

src/spatialdata_plot/pl/render.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1091,9 +1091,13 @@ def _render_points(
10911091
color_vector = np.asarray([_hex_no_alpha(c) for c in color_vector])
10921092

10931093
shade_how = render_params.density_how if render_params.density else "linear"
1094+
# Plain density (no color column) must use the user-facing cmap as a sequential
1095+
# gradient over counts; the categorical path collapses to a single color and only
1096+
# modulates alpha, which renders as a flat hue regardless of density.
1097+
plain_density = render_params.density and col_for_color is None
10941098

10951099
nan_shaded = None
1096-
if color_by_categorical or col_for_color is None:
1100+
if not plain_density and (color_by_categorical or col_for_color is None):
10971101
shaded = _ds_shade_categorical(
10981102
agg,
10991103
color_key,
-31.3 KB
Binary file not shown.
-31.3 KB
Binary file not shown.
-31.3 KB
Binary file not shown.

0 commit comments

Comments
 (0)