How to create a proportional (pre-define boundaries) colour bar with python bokeh library

Hi @daochu66 As of Bokeh 1.3.4, Bokeh only has linear and log color mappers. There is no built-in notion of a “segmented” color mapper. I think you could effectively accomplish this, though, by creating a larger palette with 100 entries, that provides the “breaks” you want implicitly. E.g.

palette = [ "yellow" ]*5 + ["pink"]*20 + ["red"]*50 + ...

Then this palette could be used with a LinearColorMapper with low, high = (0, 100).

A segmented color mapper would be a reasonable ask for a new feature, and also an excellent self-contained task for a new contributor. Please feel free to make a GitHub issue to discuss it.

As an aside, I also notice you made an SO question about this. If you could delete the question there, so as not to leave lingering unanswered questions on the bokeh tag (or self-answer it, as you prefer) it would be appreciated.

1 Like