-
-
Notifications
You must be signed in to change notification settings - Fork 8.1k
Closed
Milestone
Description
Describe the issue
Matplotlib 3.4 introduces a UserWarning with 1a9dacf when attempting to register a color map by the same name twice. So for a lame luser like myself, how am I to know if my colormap name has already been registered? Is there public API to check if a given cmap name exists?
Proposed fix
Presently, I only see this option via "private" API to check this situation
from matplotlib import cm
def cmap_exists(name):
return name in cm.__builtin_cmapsOtherwise, there would be this lame workaround
from matplotlib import cm
def cmap_exists(name):
try:
cm.get_cmap(name)
return True
except ValueError:
pass
return FalseHopefully I am not missing something obvious. If something exists, it would be nice to enhance the UserWarning by saying "Trying to register the cmap {name!r} which already exists. Please first check presence of cmap by calling cm.cmap_exists(name)"
Thank you!
ccneko