Reputation: 21961
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
I am trying to set the first color of a matplotlib colormap to gray, but getting error above. how to fix it?
Upvotes: 0
Views: 343
Reputation: 2401
without installing the module palettetable, I think the error is that you are indexing a vector with () rather than [] as python syntax (!). This way python thinks you are assigning a value to a function call, that doesn't make sense, example:
>>cmap(0)=1
File "<ipython-input-38-db88980f3077>", line 1
cmap(0)=1
SyntaxError: can't assign to function call
Upvotes: 1