I have created a simple horizontal stacked bar chart from 0 to 100% which take only two data to know the balance between the two. I would like to be able to write the values of them inside the bar (in the middle of it if possible). But even if this example looks similar, I can't find a way to adapt it to my horizontal stacked bar chart.
So far, here is my code :
colors = ["blue", "red"]
choose = ["a", "b"]
y_axis = ['Percent']
# For example for 60.1% and 39.9%
data = {'y' : y_axis,
'a' : [60.1],
'b' : [39.9]}
p = figure(y_range=y_axis, plot_height=150, x_range=(0, 100), title="TITLE", toolbar_location=None)
p.hbar_stack(choose, y='y', height=0.6, color=colors, source=ColumnDataSource(data))
p.add_tools(HoverTool(tooltips=[("A", "@a{1.1}%"), ("B", "@b{1.1}%")]))
labels = LabelSet(x=choose, y=y_axis, text=choose, level='glyph',
x_offset=-13.5, y_offset=0, source=ColumnDataSource(data), render_mode='canvas')
p.add_tools(labels) # Can we do that ?
p.ygrid.grid_line_color = None
p.axis.minor_tick_line_color = None
p.outline_line_color = None