Skip to content

Fix passing Colormap objects#188

Closed
aeisenbarth wants to merge 1 commit intoscverse:mainfrom
aeisenbarth:cmap-object
Closed

Fix passing Colormap objects#188
aeisenbarth wants to merge 1 commit intoscverse:mainfrom
aeisenbarth:cmap-object

Conversation

@aeisenbarth
Copy link
Copy Markdown
Contributor

When passing a Colormap instance via cmap, an error is raised although it is supported according to documentation.

  File "…/site-packages/spatialdata_plot/pl/basic.py", line 370, in render_images
    cmap_params = _prepare_cmap_norm(
  File "…/site-packages/spatialdata_plot/pl/utils.py", line 339, in _prepare_cmap_norm
    cmap = copy(matplotlib.colormaps[rcParams["image.cmap"] if cmap is None else cmap])
  File "…/site-packages/matplotlib/cm.py", line 80, in __getitem__
    return self._cmaps[item].copy()
TypeError: unhashable type: 'ListedColormap'

This change looks up a colormap by name only if a string is passed.

@timtreis
Copy link
Copy Markdown
Member

timtreis commented Dec 8, 2023

Hey @aeisenbarth, (again :D) many thanks for your suggestion and the code contribution! @Sonja-Stockhaus has moved your changes over to #194 so that we could add tests and slight modifications. So we'll close this one here now.

@timtreis timtreis closed this Dec 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants