Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/flash/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 将matplotlib颜色贴图的第一种颜色设置为灰色_Python_Matplotlib - Fatal编程技术网

Python 将matplotlib颜色贴图的第一种颜色设置为灰色

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

我试图将matplotlib colormap的第一种颜色设置为灰色,但上面出现了错误。如何修复它?

无需安装模块调色板, 我认为错误在于您正在使用python语法而不是[]索引向量!。 python这样认为是在给函数调用赋值,这是没有意义的,例如:

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