Python 将matplotlib颜色贴图的第一种颜色设置为灰色
我试图将matplotlib colormap的第一种颜色设置为灰色,但上面出现了错误。如何修复它?无需安装模块调色板, 我认为错误在于您正在使用python语法而不是[]索引向量!。 python这样认为是在给函数调用赋值,这是没有意义的,例如:Python 将matplotlib颜色贴图的第一种颜色设置为灰色,python,matplotlib,Python,Matplotlib,我试图将matplotlib colormap的第一种颜色设置为灰色,但上面出现了错误。如何修复它?无需安装模块调色板, 我认为错误在于您正在使用python语法而不是[]索引向量!。 python这样认为是在给函数调用赋值,这是没有意义的,例如: import palettable cmap = palettable.colorbrewer.sequential.PuRd_9.mpl_colormap cmap(0) = (.5, .5, .5, 1.0) # force the first
import palettable
cmap = palettable.colorbrewer.sequential.PuRd_9.mpl_colormap
cmap(0) = (.5, .5, .5, 1.0) # force the first color entry to be grey
*** SyntaxError: can't assign to function call
>>cmap(0)=1
File "<ipython-input-38-db88980f3077>", line 1
cmap(0)=1
SyntaxError: can't assign to function call