将matplotlib色彩映射的第一种颜色设置为灰色

时间:2017-02-07 01:30:44

标签: python matplotlib

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

我正在尝试将matplotlib色彩映射的第一种颜色设置为灰色,但上面会出现错误。如何解决?

1 个答案:

答案 0 :(得分:1)

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

padding