☰Read-only archive⌕
Looking for help with Bokeh?

This is a read-only archive. Ask questions and join the conversation on GitHub.

Visit Community Support on GitHub →
Archived discussions · Captured October 28, 2026

How to use lookup table based colormap for heatmap in Bokeh?

Community Support
Amit_Chourasia
Amit_Chourasia

Bokeh assigns automatic colors for heat map, for example here where colors are assigned to automatically determined range (bins)

from bokeh.charts import HeatMap, bins, output_file, show
from bokeh.layouts import column, gridplot
from bokeh.palettes import RdYlGn6, RdYlGn9

fruits = {'fruit': ['apples', 'apples', 'apples', 'apples', 'apples',
                    'pears', 'pears', 'pears', 'pears', 'pears',
                    'bananas', 'bananas', 'bananas', 'bananas', 'bananas'],
          'fruit_count': [4, 5, 8, 12, 4, 6, 5, 4, 8, 7, 1, 2, 4, 8, 12],
          'year': [2009, 2010, 2011, 2012, 2013, 2009, 2010, 2011, 2012, 2013, 2009, 2010,
                   2011, 2012, 2013]}
fruits['year'] = [str(yr) for yr in fruits['year']]

hm = HeatMap(fruits, y='year', x='fruit', values='fruit_count', stat=None)
output_file("heatmap.html")

show(hm)

How can the colors be assigned based on a lookup table for example?

value | color
---   | ---
[0-3] | red
(3-6] | blue
(6-9] | green
(9-12] | yellow

Moreover, how can colors be assigned say when the bins are not equal in the colormap lookup table.

Cross posted this question on stack overflow

Thanks

⌁   Link to post

End of archived discussion · Replies are disabled