I’m trying to use LabelSet with hbar plot, but the labels are not displaying. What am I doing wrong?
from bokeh.plotting import figure
from bokeh.models import ColumnDataSource, LabelSet
from bokeh.plotting import curdoc
y = ['cat1', 'cat2', 'cat3', 'cat4']
source = ColumnDataSource(
data = {
'y': y,
'right': [30,40,20,70],
'right_labels': ['30%', '40%', '20%', '70%']
}
)
fig = figure(
x_range=[0,100],
y_range=y,
)
fig.hbar(
y='y',
left=0,
right='right',
height=.5,
source=source,
)
labels = LabelSet(
y='y',
x='right',
text='right_labels',
source=source,
)
fig.add_layout(labels)
curdoc().add_root(fig)
Thanks!