Wrapping text in text glyph

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.

Has there been any update in order to be able to support multiline text glyphs?

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)
show(sample)

I’ve also encountered the same issue and wonder if there’s an easy or common workaround??

···

On Thursday, June 23, 2016 at 4:01:51 PM UTC-4, Ari Krumbein wrote:

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.

Has there been any update in order to be able to support multiline text glyphs?

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)
show(sample)

Te xt-wrapping on canvas
isn’t available in Bokeh - I agree it’d be nice
though. I’d suggest opening an issue
if there isn’t one.

                            The only possible

path to a workaround that I can think of

  • I haven’t tried this i t’s just an
    idea. Use
    a Label/LabelSet annotation and set the
    render-mode to be css. Once it’s
    in CSS you may be able to target
    the objects with manual css to
    set
    their width and have them wrap. Just to
    re iterated
    it’s only an idea.
···

On 8/6/16 12:07 PM, wrote:

[email protected]

    I've also encountered the same issue and wonder if

there’s an easy or common workaround??

    On Thursday, June 23, 2016 at 4:01:51 PM UTC-4, Ari Krumbein

wrote:

          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.

        Has there been any update in order to be able to support

multiline text glyphs?

                      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)

          show(sample)

  You received this message because you are subscribed to the Google

Groups “Bokeh Discussion - Public” group.

  To unsubscribe from this group and stop receiving emails from it,

send an email to [email protected].

  To post to this group, send email to [email protected]

  To view this discussion on the web visit [https://groups.google.com/a/continuum.io/d/msgid/bokeh/46044fc6-eef0-4b6e-af9e-1d4267e242b0%40continuum.io](https://groups.google.com/a/continuum.io/d/msgid/bokeh/46044fc6-eef0-4b6e-af9e-1d4267e242b0%40continuum.io?utm_medium=email&utm_source=footer).

  For more options, visit [https://groups.google.com/a/continuum.io/d/optout](https://groups.google.com/a/continuum.io/d/optout).


Sarah Bird
Developer, Bokeh

    [
      ![Continuum Analytics](http://docs.continuum.io/_static/img/ContinuumWordmark.png)
    ](http://continuum.io)