☰Read-only archive⌕
Looking for help with Bokeh?

This is a read-only archive. Ask questions and join the conversation on GitHub.

Visit Community Support on GitHub →
Archived discussions · Captured October 28, 2026

Bokeh 0.9: Explicitly defining Text Glyph Attributes without a ColumnDataSource doesn't work!

Community Support
Chris_Lindner
Chris_Lindner

If I try to add a Text Glyph to the example in https://github.com/bokeh/bokeh/blob/master/tests/glyphs/Text.py with
glyph = Text(x=0, y=1, text=“hello world”, angle=0.3, text_color="#96deb3")

plot.add_glyph(glyph)

``

The glyph text comes out as “NaN” instead of “hello world.”

Similarly, if I try to add a text glyph to a figure like this

myfig.text(

[plot_width/2.0]

,[current_y]

,text = ‘Cluster Information’

,text_align=‘center’

,text_font_size=‘20pt’

,alpha=0.8

,text_font_style=‘bold’

)

``

I get the error:

RuntimeError: Column name ‘Cluster Information’ does not appear in data source <bokeh.models.sources.ColumnDataSource object at 0x11610e190>

``

as though it’s looking in a ColumnDataSource, even though I haven’t specified one. This used to work in 0.82. How can I explicitly define a text glyph without having to use a ColumnDataSource in 0.9?

⌁   Link to post
Chris_Lindner
Chris_Lindner

Okay, in fiddling with this, I think I found the fix. It looks like Bokeh 0.9 will assume your text is a label unless you put it in a list. Thus, the new Bokeh way to do this is
glyph = Text(x=[0], y=[1], text=[“hello world”], angle=0.3, text_color=“#96deb3”)

plot.add_glyph(glyph)

``

This is kind of an annoying change. I didn’t tell Bokeh I wanted to use a ColumnDataSource, so why is it assuming I do?

···

On Thursday, May 21, 2015 at 4:59:27 PM UTC-5, Chris Lindner wrote:

If I try to add a Text Glyph to the example in https://github.com/bokeh/bokeh/blob/master/tests/glyphs/Text.py with
glyph = Text(x=0, y=1, text=“hello world”, angle=0.3, text_color=“#96deb3”)

plot.add_glyph(glyph)

``

The glyph text comes out as “NaN” instead of “hello world.”

Similarly, if I try to add a text glyph to a figure like this

myfig.text(

[plot_width/2.0]

,[current_y]

,text = ‘Cluster Information’

,text_align=‘center’

,text_font_size=‘20pt’

,alpha=0.8

,text_font_style=‘bold’

)

``

I get the error:

RuntimeError: Column name ‘Cluster Information’ does not appear in data source <bokeh.models.sources.ColumnDataSource object at 0x11610e190>

``

as though it’s looking in a ColumnDataSource, even though I haven’t specified one. This used to work in 0.82. How can I explicitly define a text glyph without having to use a ColumnDataSource in 0.9?

⌁   Link to post
Bryan
Bryan

Hi Chris,

In every other glyph, a string value is always interpreted as "column label". This change brings consistency to *all* Bokeh glyphs. Doing that reduces unnecessary code-paths branches and complications in the implementation, but much more importantly allows all the glyphs to be documented straightforwardly, without confusing "but things are different for this special case" exceptions.

One unavoidable confusing aspect of Bokeh is the implications of the cross language serialization, where things are defined in one place and time in one language, but not actually used until a later time and place in a different language. The Bokeh python binding is not assuming you are using a column data source, it simply has no way whatsoever of knowing you won't add one at some point. In this case, the consistency and explicitness described above is more valuable than trying to make guesses about what users want, that are sometimes convenient, except when they aren't.

Thanks,

Bryan

···

On May 21, 2015, at 5:08 PM, Chris Lindner <christopherclindner@gmail.com> wrote:

Okay, in fiddling with this, I think I found the fix. It looks like Bokeh 0.9 will assume your text is a label unless you put it in a list. Thus, the new Bokeh way to do this is
glyph = Text(x=[0], y=[1], text=["hello world"], angle=0.3, text_color="#96deb3")
plot.add_glyph(glyph)
This is kind of an annoying change. I didn't tell Bokeh I wanted to use a ColumnDataSource, so why is it assuming I do?

On Thursday, May 21, 2015 at 4:59:27 PM UTC-5, Chris Lindner wrote:
If I try to add a Text Glyph to the example in https://github.com/bokeh/bokeh/blob/master/tests/glyphs/Text.py with
glyph = Text(x=0, y=1, text="hello world", angle=0.3, text_color="#96deb3")
plot.add_glyph(glyph)
The glyph text comes out as "NaN" instead of "hello world."

Similarly, if I try to add a text glyph to a figure like this
myfig.text(
            [plot_width/2.0]
            ,[current_y]
            ,text = 'Cluster Information'
            ,text_align='center'
            ,text_font_size='20pt'
            ,alpha=0.8
            ,text_font_style='bold'
           )
I get the error:
RuntimeError: Column name 'Cluster Information' does not appear in data source <bokeh.models.sources.ColumnDataSource object at 0x11610e190>
as though it's looking in a ColumnDataSource, even though I haven't specified one. This used to work in 0.82. How can I explicitly define a text glyph without having to use a ColumnDataSource in 0.9?

--
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 bokeh+unsubscribe@continuum.io.
To post to this group, send email to bokeh@continuum.io.
To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/0680a002-7574-4abb-984a-242c76f1f3bf%40continuum.io\.
For more options, visit https://groups.google.com/a/continuum.io/d/optout\.

⌁   Link to post
Bryan
Bryan

BTW, this should work for fixed values of x and y:

  glyph = Text(x=0, y=1, text=["hello world"], angle=0.3, text_color="#96deb3")
  plot.add_glyph(glyph)

Turning single values into columns internally is purely a convenience, but a reasonable one to do when it can be done without adding confusion or inconsistency, i.e., when the values are not strings.

Thanks,

Bryan

···

On May 21, 2015, at 5:08 PM, Chris Lindner <ChristopherCLindner@gmail.com> wrote:

glyph = Text(x=[0], y=[1], text=["hello world"], angle=0.3, text_color="#96deb3")
plot.add_glyph(glyph)

⌁   Link to post
zork306
zork306

Thanks for the prompt response!

I definitely understand the push for uniformity, but to the end user I think it still feels a little odd that the function assumes (and apparently creates) a ColumnDataSource even when I haven’t specified one.

Anyway, it wasn’t too horrible to fix, it was just unclear what the problem was when I first encountered it.

···

On Thursday, May 21, 2015 at 7:38:17 PM UTC-5, Bryan Van de ven wrote:

Hi Chris,

In every other glyph, a string value is always interpreted as “column label”. This change brings consistency to all Bokeh glyphs. Doing that reduces unnecessary code-paths branches and complications in the implementation, but much more importantly allows all the glyphs to be documented straightforwardly, without confusing “but things are different for this special case” exceptions.

One unavoidable confusing aspect of Bokeh is the implications of the cross language serialization, where things are defined in one place and time in one language, but not actually used until a later time and place in a different language. The Bokeh python binding is not assuming you are using a column data source, it simply has no way whatsoever of knowing you won’t add one at some point. In this case, the consistency and explicitness described above is more valuable than trying to make guesses about what users want, that are sometimes convenient, except when they aren’t.

Thanks,

Bryan

On May 21, 2015, at 5:08 PM, Chris Lindner christoph...@gmail.com wrote:

Okay, in fiddling with this, I think I found the fix. It looks like Bokeh 0.9 will assume your text is a label unless you put it in a list. Thus, the new Bokeh way to do this is

glyph = Text(x=[0], y=[1], text=[“hello world”], angle=0.3, text_color=“#96deb3”)

plot.add_glyph(glyph)

This is kind of an annoying change. I didn’t tell Bokeh I wanted to use a ColumnDataSource, so why is it assuming I do?

On Thursday, May 21, 2015 at 4:59:27 PM UTC-5, Chris Lindner wrote:

If I try to add a Text Glyph to the example in https://github.com/bokeh/bokeh/blob/master/tests/glyphs/Text.py with

glyph = Text(x=0, y=1, text=“hello world”, angle=0.3, text_color=“#96deb3”)

plot.add_glyph(glyph)

The glyph text comes out as “NaN” instead of “hello world.”

Similarly, if I try to add a text glyph to a figure like this

myfig.text(

        [plot_width/2.0]
        ,[current_y]
        ,text = 'Cluster Information'
        ,text_align='center'
        ,text_font_size='20pt'
        ,alpha=0.8
        ,text_font_style='bold'
       )

I get the error:

RuntimeError: Column name ‘Cluster Information’ does not appear in data source <bokeh.models.sources.ColumnDataSource object at 0x11610e190>

as though it’s looking in a ColumnDataSource, even though I haven’t specified one. This used to work in 0.82. How can I explicitly define a text glyph without having to use a ColumnDataSource in 0.9?

–
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 bokeh+un...@continuum.io.

To post to this group, send email to bo...@continuum.io.

To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/0680a002-7574-4abb-984a-242c76f1f3bf%40continuum.io.

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

⌁   Link to post
Bryan
Bryan

Yup, and the feedback is welcome I will definitely make some docs edits about this.

BTW just for information, all Bokeh glyphs ultimately use some kind of DataSource objects, and typically ColumnDataSources. Part of the benefit of bokeh.plotting and bokeh.charts interfaces is that in many cases those can transparently be created for you so that you don't have to worry about it.

Thanks,

Bryan

···

On May 22, 2015, at 1:18 PM, zork306@gmail.com wrote:

Thanks for the prompt response!

I definitely understand the push for uniformity, but to the end user I think it still feels a little odd that the function assumes (and apparently creates) a ColumnDataSource even when I haven't specified one.

Anyway, it wasn't too horrible to fix, it was just unclear what the problem was when I first encountered it.

⌁   Link to post

End of archived discussion · Replies are disabled