Is it possible to wrap text after some width for long labels? I’ve got a big technical name that I can’t shorten without making the vis inaccurate or misleading and it’s taking up far too much space.
There doesn’t seem to be anything listed in text properties, so I’m unsure where to go from here.
Here’s a minimal example to demonstrate:
from pandas import *
from bokeh.io import show
from bokeh.models import LinearColorMapper, ColumnDataSource
from bokeh.plotting import figure
from bokeh.palettes import Viridis256
df = DataFrame({'attribute': ['long name that cant be shortened, would like to wrap text instead', 'long name that cant be shortened, would like to wrap text instead', 'long name that cant be shortened, would like to wrap text instead', 'long name that cant be shortened, would like to wrap text instead', 'Z', 'Z', 'Z', 'Z']
, 'period': ['1', '2', '3', '4', '1', '2', '3', '4']
, 'dimension_1': [1, 37, 44, 13, 41, 51, 18, 14]})
periods = df.period.unique().tolist()
attributes = df.attribute.unique().tolist()
source = ColumnDataSource(data=df)
color_mapper = LinearColorMapper(palette=Viridis256, low=df.dimension_1.min(),
high=df.dimension_1.max())
p = figure(x_range=periods, y_range=attributes)
p.rect(x="period", y="attribute", width=1, height=1, line_color=None, source=source,
fill_color={'field': 'dimension_1', 'transform': color_mapper})
show(p)