Skip to content

Commit 09a31ad

Browse files
Sonja-StockhausSonja Stockhaus
and
Sonja Stockhaus
authored
Plotting of continuous values when norm=None (#201)
* add case for when norm=None to enable plotting of continuous value * test and changelog * update test image --------- Co-authored-by: Sonja Stockhaus <[email protected]>
1 parent 9bb23e6 commit 09a31ad

File tree

4 files changed

+7
-1
lines changed

4 files changed

+7
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ and this project adheres to [Semantic Versioning][].
2323
- Now dropping index when plotting shapes after spatial query (#177)
2424
- Points are now being correctly rotated (#198)
2525
- User can now pass Colormap objects to the cmap argument in render_images. When only one cmap is given for 3 channels, it is now applied to each channel (#188, #194)
26+
- Labels can now be colored by a continuous variable without setting `norm` (#201)
2627

2728
## [0.0.6] - 2023-11-06
2829

src/spatialdata_plot/pl/utils.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,9 @@ def _prepare_cmap_norm(
353353

354354
cmap.set_bad("lightgray" if na_color is None else na_color)
355355

356-
if isinstance(norm, Normalize) or not norm:
356+
if norm is None:
357+
norm = Normalize(vmin=vmin, vmax=vmax)
358+
elif isinstance(norm, Normalize) or not norm:
357359
pass # TODO
358360
elif vcenter is None:
359361
norm = Normalize(vmin=vmin, vmax=vmax)
Loading

tests/pl/test_render_labels.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,3 +70,6 @@ def test_plot_can_stack_render_labels(self, sdata_blobs: SpatialData):
7070
)
7171
.pl.show()
7272
)
73+
74+
def test_plot_can_color_labels_by_continuous_variable(self, sdata_blobs: SpatialData):
75+
sdata_blobs.pl.render_labels("blobs_labels", color="channel_0_sum").pl.show()

0 commit comments

Comments
 (0)