python
config_error
ai_generated
true
ValueError: 'viridis_r' 不是 cmap 的有效值;支持的值包括:'viridis', 'plasma', ...
ValueError: 'viridis_r' is not a valid value for cmap; supported values are: 'viridis', 'plasma', ...
ID: python/matplotlib-cmap-not-recognized
80%修复率
87%置信度
0证据数
2024-10-02首次发现
版本兼容性
| 版本 | 状态 | 引入 | 弃用 | 备注 |
|---|---|---|---|---|
| 3.x | active | — | — | — |
根因分析
传入了 matplotlib 无法识别的 colormap 名称,通常是由于拼写错误或由其他库(如 cmocean)注册但未安装的 colormap。
English
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.
解决方案
-
95% 成功率
import matplotlib.pyplot as plt print(list(plt.colormaps())) ax.imshow(data, cmap='viridis_r')
-
90% 成功率
pip install cmocean import cmocean ax.imshow(data, cmap='cmo.thermal')
无效尝试
常见但无效的做法:
-
80% 失败
Falls back to the default colormap, silently changing the intended visualization.
-
90% 失败
Also invalid; the correct suffix is '_r'.