Is there an option to get the values of a color mapper transform?

I’m currently using the color mapper like this:

# color mapper
mapper = LinearColorMapper(palette=RdBu[11][::-1], low=-1, high=1, nan_color='lightgray')
# plot
plot = figure(...)
plot.rect(x="x", y="y", fill_color=transform("value", mapper))

The thing is that my nan values are split to two different cases and I need them to be colored differently.
I was thinking, if it’s possible somehow to get the actual color values from the transform, then I could create a “color” column in the data source and handle the nan colors myself.
Is this possible? If not, any other ideas?

When using LinearColorMapper, the color mapping only happens in the browser, in Javascript. There is no point that the mapped colors are available in Python code. Offhand ideas:

  • Don’t use LinearColorMapper. Manually colormap the all values yourself, and store them in an explicit CDS column. I’d expect this to be ~10 lines of Python code.

  • In you don’t need to use the high_color or low_color options of LinearColorMapper, then you could explicitly configure high or low on the color mapper, and change some of the NaN values to be arbitrary values above or below the high or low properties, then high_color or low_color would be used for those values.

The only other idea I can think of is the ever-present possibility to create a Custom Extension that knows how to do this specialized colormapping in JavaScript.

that was quick…thanks @Bryan !