I'm trying to change the colormap used by datashader.
I tried this:
datashade(scatter, cmap='Reds')
Where scatter
is an hv.Scatter
element. This doesn't work because datashader expects an iterable or a function that returns colors. As such, this works:
datashade(scatter, cmap=['blue'])
So how can I take the 'Reds'
colormap and convert it into something datashader can use?
Thank you.
Right; you can't pass the string name of a colormap to Datashader's cmap
argument, because Datashader interprets a single string as the name of a single color, constructing a colormap from it by setting the R,G,B channels to that color and then varying the alpha channel. If you want a colormap, either pass a list of colors (as used by Bokeh for its palettes) or a Matplotlib colormap object (not the string name) to cmap
:
from matplotlib import cm
datashade(scatter, cmap=cm.Reds)