Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion src/spatialdata_plot/pl/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,12 @@ def _prepare_cmap_norm(
**kwargs: Any,
) -> CmapParams:
is_default = cmap is None
cmap = copy(matplotlib.colormaps[rcParams["image.cmap"] if cmap is None else cmap])
if cmap is None:
cmap = rcParams["image.cmap"]
if isinstance(cmap, str):
cmap = matplotlib.colormaps[cmap]

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

if isinstance(norm, Normalize) or not norm:
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 4 additions & 1 deletion tests/pl/test_render_images.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,12 @@ class TestImages(PlotTester, metaclass=PlotTesterMeta):
def test_plot_can_render_image(self, sdata_blobs: SpatialData):
sdata_blobs.pl.render_images(elements="blobs_image").pl.show()

def test_plot_can_pass_cmap_to_render_images(self, sdata_blobs: SpatialData):
def test_plot_can_pass_cmap_name_to_render_images(self, sdata_blobs: SpatialData):
sdata_blobs.pl.render_images(elements="blobs_image", cmap="seismic").pl.show()

def test_plot_can_pass_cmap_object_to_render_images(self, sdata_blobs: SpatialData):
sdata_blobs.pl.render_images(elements="blobs_image", cmap=matplotlib.colormaps["seismic"]).pl.show()

def test_plot_can_render_a_single_channel_from_image(self, sdata_blobs: SpatialData):
sdata_blobs.pl.render_images(elements="blobs_image", channel=0).pl.show()

Expand Down