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

ValueError: Re-registering the builtin cmap 'Set1' is not allowed. #295

Open
liangyuli12138 opened this issue Dec 2, 2024 · 1 comment

Comments

@liangyuli12138
Copy link

Hi, I was learning the turtual about this : https://spateo-release.readthedocs.io/en/latest/tutorials/notebooks/5_cluster_digitization/5_borderline_digitization.html

But I get this erro information

st.pl.space(adata, space = "cellbin_spatial", color=['score'], pointsize=0.2,cmap="Set1", show_legend="upper left")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/share/appspace_data/shared_groups/BGI/USERS/bgi_lily/env/Spateo/lib/python3.11/site-packages/spateo/configuration.py", line 204, in wrapper
    return func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^
  File "/share/appspace_data/shared_groups/BGI/USERS/bgi_lily/env/Spateo/lib/python3.11/site-packages/spateo/plotting/static/space.py", line 132, in space
    res = scatters(
          ^^^^^^^^^
  File "/share/appspace_data/shared_groups/BGI/USERS/bgi_lily/env/Spateo/lib/python3.11/site-packages/spateo/configuration.py", line 204, in wrapper
    return func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^
  File "/share/appspace_data/shared_groups/BGI/USERS/bgi_lily/env/Spateo/lib/python3.11/site-packages/spateo/plotting/static/scatters.py", line 997, in scatters
    _plot_basis_layer(cur_b, cur_l)
  File "/share/appspace_data/shared_groups/BGI/USERS/bgi_lily/env/Spateo/lib/python3.11/site-packages/spateo/plotting/static/scatters.py", line 864, in _plot_basis_layer
    ax, color_out = _matplotlib_points(
                    ^^^^^^^^^^^^^^^^^^^
  File "/share/appspace_data/shared_groups/BGI/USERS/bgi_lily/env/Spateo/lib/python3.11/site-packages/spateo/plotting/static/utils.py", line 600, in _matplotlib_points
    mpl.colormaps.register(name=cmap_.name, cmap=cmap_, force=True)
  File "/share/appspace_data/shared_groups/BGI/USERS/bgi_lily/env/Spateo/lib/python3.11/site-packages/matplotlib/cm.py", line 142, in register
    raise ValueError("Re-registering the builtin cmap "
ValueError: Re-registering the builtin cmap 'Set1' is not allowed.
@lcmmichielsen
Copy link

lcmmichielsen commented Dec 4, 2024

I experienced the same error and guess it has something to do with the matplotlib version. As a workaround I cloned this GitHub repo and commented out this line 600 in the utils.py file:

# mpl.colormaps.register(name=cmap_.name, cmap=cmap_, force=True)

I also had to change line 788 in the same file to this:

cb._draw_all()

Afterwards I could install the package using pip install . and plotting worked.

Hope this works for you as well!

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

No branches or pull requests

2 participants