Bokeh: CategoricalColorMapper ColorBar

Created on 27 Dec 2016  路  4Comments  路  Source: bokeh/bokeh

I have a use case for CategoricalColorMapper to work with the ColorBar class similar to how LinearColorMapper works

The default behavior would be to display the Categorical names next to the particular color value.

tag bokehjs feature

Most helpful comment

@bryevdv thank you, I should have been more clear in my previous post.

It is nice how the ColorBar class works with a LinearColorMapper:

mapper = bkmap.LinearColorMapper(palette=colors, low=min_val, high=max_val)
color_bar = ColorBar(color_mapper=mapper, ticker=FixedTicker(ticks=ticks), 
                     label_standoff=12, location=(0,0))
plot.add_layout(color_bar,'right')

It would be nice if the ColorBar class would work the same with a CategoricalColorMapper:

mapper = bkmap.CategoricalColorMapper(factors=categories, palette=colors)
color_bar = ColorBar(color_mapper=mapper, label_standoff=12, location=(0,0))

Extra nice if the ColorBar class automatically detected how the factors were mapped to colors and applied tick marks like so:
image

All 4 comments

@js3711 can you elaborate some? Things that are helpful for feature requests:

  • detailed description of need
  • references to similar examples in other systems
  • API / sample code proposals to consider

@bryevdv thank you, I should have been more clear in my previous post.

It is nice how the ColorBar class works with a LinearColorMapper:

mapper = bkmap.LinearColorMapper(palette=colors, low=min_val, high=max_val)
color_bar = ColorBar(color_mapper=mapper, ticker=FixedTicker(ticks=ticks), 
                     label_standoff=12, location=(0,0))
plot.add_layout(color_bar,'right')

It would be nice if the ColorBar class would work the same with a CategoricalColorMapper:

mapper = bkmap.CategoricalColorMapper(factors=categories, palette=colors)
color_bar = ColorBar(color_mapper=mapper, label_standoff=12, location=(0,0))

Extra nice if the ColorBar class automatically detected how the factors were mapped to colors and applied tick marks like so:
image

@js3711 Thanks for the additional information. I agree this would be a useful addition. There is some planned work to improve how categorically are handled generally in Bokeh, and it probably makes sense to get that work out of the way first.

That said, I do think that "categorical-like" labels on colorbars are currently accomplishable using custom tick formatters.

ping @birdsarah for FYI and any thoughts

I'm going to unmark this as GFI because I expect it might actually be fairly involved. Also adding to 2.3 because I think it is fairly overdue.

Was this page helpful?
0 / 5 - 0 ratings