GitHub以及matplotlib官网链接:
API Changes for 3.9.0 — Matplotlib 3.9.0 documentation
在python版本高于3.9.0以后,绘图工具matplotlib内置的cm函数发生变化,删除cm函数。此时再需要调用cmap函数,需要
-
matplotlib.cm.get_cmap
代替为matplotlib.colormaps[name]
-
matplotlib.cm.register_cmap
; use matplotlib.colormaps.register instead. -
matplotlib.cm.unregister_cmap
; use matplotlib.colormaps.unregister instead. -
matplotlib.pyplot.register_cmap
; use matplotlib.colormaps.register instead.
对于头文件的修改
原有:from matplotlib.cm import register_cmap
改为:from matplotlib import colormaps
更改后即可使用