python
config_error
ai_generated
true
ValueError: 'viridis_r' is not a valid value for cmap; supported values are: 'viridis', 'plasma', ...
ID: python/matplotlib-cmap-not-recognized
80%Fix Rate
87%Confidence
0Evidence
2024-10-02First Seen
Version Compatibility
| Version | Status | Introduced | Deprecated | Notes |
|---|---|---|---|---|
| 3.x | active | — | — | — |
Root Cause
Passing a colormap name that matplotlib does not recognize, often due to a typo or a colormap registered by a different library (e.g., cmocean) that is not installed.
generic中文
传入了 matplotlib 无法识别的 colormap 名称,通常是由于拼写错误或由其他库(如 cmocean)注册但未安装的 colormap。
Workarounds
-
95% success
import matplotlib.pyplot as plt print(list(plt.colormaps())) ax.imshow(data, cmap='viridis_r')
-
90% success
pip install cmocean import cmocean ax.imshow(data, cmap='cmo.thermal')
Dead Ends
Common approaches that don't work:
-
80% fail
Falls back to the default colormap, silently changing the intended visualization.
-
90% fail
Also invalid; the correct suffix is '_r'.