Hi there, new to Bokeh and working on a project in plotting. I’ve combed the documentation for plotting and text glyphs as well as the mailing list (found this topic) but I’ve come up short; hoping you guys can help. Based on this issue, it would appear several people have encountered it in the past.
I have no problem placing some text on some rectangle glyphs, but in several cases with my own data, the strings are excessively long, as shown below, and could use some wrapping. I’ve tried a few crude solutions, including replacing spaces in the strings with newlines, but found these were not respected upon rendering the plot. I’ve also considered placing multiple staggered text glyphs, but this seems like too much work for the task.
sample = figure(height = 700, width = 900, x_range = Range1d(1,6), y_range = Range1d(1,4))
xs = [2,3,4,5]
ys = [3,3,3,3]
words = [ “This is a really long string”, “This is a string too”, “This is also a string”, “This string”]
source = ColumnDataSource(data=dict(
text = words,
text_x = [x - 0.30 for x in xs]
sample.rect(xs,ys, 0.75, 1)
sample.text(“text_x”, ys, text = “text”, source = source)