Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix passing Colormap objects #188

Closed
wants to merge 1 commit into from

Conversation

aeisenbarth
Copy link
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
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