Search code examples
bokeh

How can I add text annotation in Bokeh?


I'm looking for Matplotlib type 1 text annotation in Bokeh, but I couldn't find it in the their user guide 2 or in the references.


Solution

  • As of version 0.12.2, to add text annotations you would use the "label" glyph.

    from bokeh.models import Label
    
    p = figure(...)
    
    mytext = Label(x=70, y=70, text='here your text')
    
    p.add_layout(mytext)
    
    show(p)
    

    Please find a full example in the documentation: http://docs.bokeh.org/en/latest/docs/user_guide/annotations.html#userguide-annotations