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

matplotlib gives error if colormap already registered, problem in colorize #207

Open
sgiardie opened this issue Feb 21, 2023 · 0 comments
Open

Comments

@sgiardie
Copy link

  • pixell version: 0.17.1
  • Python version: 3.8.15
  • Operating System: Linux

Description

colorize.mpl_setdefault breaks if a colormap is already registered in matplotlib. For example, I was using
colorize.mpl_setdefault('planck'), causing the error
ValueError: A colormap named "planck" is already registered.

What I Did

I modified the colorize.mpl_register function with a try/except block:

for name in names:
    cmap = to_mpl_colormap(name, schemes[name])
    try:
        matplotlib.cm.register_cmap(name, cmap)
    except:
        pass
@sgiardie sgiardie changed the title matplotlib breaks if colormap already registered, problem in colorize matplotlib gives error if colormap already registered, problem in colorize Feb 21, 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

No branches or pull requests

1 participant