Skip to content

Commit

Permalink
Plotting of continuous values when norm=None (#201)
Browse files Browse the repository at this point in the history
* 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]>
  • Loading branch information
Sonja-Stockhaus and Sonja Stockhaus authored Jan 9, 2024
1 parent 9bb23e6 commit 09a31ad
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ and this project adheres to [Semantic Versioning][].
- Now dropping index when plotting shapes after spatial query (#177)
- Points are now being correctly rotated (#198)
- 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)
- Labels can now be colored by a continuous variable without setting `norm` (#201)

## [0.0.6] - 2023-11-06

Expand Down
4 changes: 3 additions & 1 deletion src/spatialdata_plot/pl/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,9 @@ def _prepare_cmap_norm(

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

if isinstance(norm, Normalize) or not norm:
if norm is None:
norm = Normalize(vmin=vmin, vmax=vmax)
elif isinstance(norm, Normalize) or not norm:
pass # TODO
elif vcenter is None:
norm = Normalize(vmin=vmin, vmax=vmax)
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions tests/pl/test_render_labels.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,3 +70,6 @@ def test_plot_can_stack_render_labels(self, sdata_blobs: SpatialData):
)
.pl.show()
)

def test_plot_can_color_labels_by_continuous_variable(self, sdata_blobs: SpatialData):
sdata_blobs.pl.render_labels("blobs_labels", color="channel_0_sum").pl.show()

0 comments on commit 09a31ad

Please sign in to comment.