The ticks in ColorBar cannot be displayed

I created a independent colorbar with EqHistColorMapper and any one type of Ticker, but no any ticks on it, and, if I used the LinearColorMapper and FixedTicker or SingleIntervalTicker, this problem did not arise, could anybody tell me how to solve this problem?

example codes:

from bokeh.plotting import show, row
from bokeh.plotting import figure
from bokeh.models import ColorBar, LinearColorMapper, EqHistColorMapper,BinnedTicker
from colorcet import palette

color_mapper = EqHistColorMapper(palette=palette['fire'], low=1, high=2000)
ticker = BinnedTicker(mapper=color_mapper)
color_bar = ColorBar(color_mapper=color_mapper, location='center_left', orientation='vertical',
                                    height=250, width=20, major_tick_line_color='black', ticker=ticker )
f = figure(width=500, height=500, toolbar_location=None, x_axis_type=None, y_axis_type=None)
f.add_layout(color_bar, 'right')
show(f)

I could be mistaken, but I believe the EqHistColorMapper actually needs to first scan an actual dataset before it can compute bins. i.e. things may not be able to function like this “in isolation”.

@mateusz or @Ian_Thomas may be able to comment for sure

Yes, an EqHistColorMapper needs to scan data to calculate the bins which determines the possible locations of ticks at bin edges. Conceptually it cannot have ticks at arbitrary locations as there is no sensible way to interpolate between bin edges. I suppose if you had a large dataset you could use a very large number of bins and choose which of the ticks to show, perhaps the nearest ticks to some desired tick locations. But this nearest tick functionality doesn’t exist in Bokeh.

1 Like