Title location in colorbar

Hi!

I’m creating a map with a geojson polygon and I added a colorbar. I’d like to put the colorbar title at the top of the bar.

This is an extract of the code I’m using with Bokeh 3.6.1 and Python 3.11

from bokeh.models import ColorBar, GeoJSONDataSource, LinearColorMapper

plot_map = figure(x_axis_type='mercator', y_axis_type='mercator', x_range=(0, 1), y_range=(0, 1), sizing_mode='stretch_width', width=1)
plot_map.add_tile('CartoDB Positron')

source_ffm  = GeoJSONDataSource(geojson=empty_geojson)
color_mapper = LinearColorMapper(palette="Plasma256", low=0, high=20)

plot_map.patches(xs='xs', ys='ys', source=source_ffm, line_color='black', line_width=1, fill_alpha=0.75, fill_color={'field': 'slip', 'transform': color_mapper})

color_bar = ColorBar(color_mapper=color_mapper, location=(0,0), title='Slip [m]', visible=True)
plot_map.add_layout(color_bar, 'right')

The data is dynamically loaded and it’s working well, but the colorbar title is always in the left side of the bar.

I’ve tried with almost all the parameters from ColorBar described in the documentation but I haven’t found a solution.

Is it possible to move the colorbar title to the top?

Thank you in advance

There is not any mechanism to control this, colorbar titles are always placed on the “long” side of a colorbar:

Ouch… well, at least I asked before spending my weekend on this. And this gave the idea of moving the colorbar to the left

It’s something.

Thank you. It’d be cool if in the future the title could be moved to different locations.

First step would be for someone to submit a GitHub Issue.

Yes, I know, and maybe I will. Some time ago I did one and also did a PR about adding the star symbol. I like to explore before asking, because I know how difficult it could be this kind of tasks :wink:

1 Like

I submitted an issue [FEATURE] Specify the title location, orientation and alignment in colorbars · Issue #14149 · bokeh/bokeh · GitHub and I’m working on a PR. Any opinion is welcome.

1 Like