Hi all,
I’m trying to make a more useful color bar when using a log scale. The issue is that the color bar’s ticks are linear, and hence not that useful (see simplified reproducible example below). Ideally, the ticks should be at the breaks (i.e. value thresholds where the colors change).
I realize I can workaround this issue by supplying those values as a list to models.FixedTicker(), but I don’t know how LogColorMapper is actually generating those breaks.
import pandas as pd
import numpy as np
from bokeh import plotting, io, models
io.output_notebook()
data = pd.DataFrame({‘x’:np.random.normal(size=100),
‘y’:np.random.normal(size=100),
‘score’:np.random.lognormal(mean=1, size=100)})
df_src = models.ColumnDataSource(data)
palette = [’#feebe2’, ‘#fa9fb5’, ‘#dd3497’, ‘#7a0177’]
mapper = models.LogColorMapper(palette=palette, low=0, high=max(data[‘score’]))
plot = plotting.figure()
plot.circle(‘x’, ‘y’, fill_color={‘field’:‘score’, ‘transform’: mapper}, size=10, source=df_src)
color_bar = models.ColorBar(color_mapper=mapper, label_standoff=10, location=‘top_left’, orientation=‘horizontal’)
plot.add_layout(color_bar)
plotting.show(plot)
``
Any help is much appreciated.