Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I add text annotation in Bokeh?

Tags:

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.

like image 934
Harsh Avatar asked Jun 07 '15 17:06

Harsh


People also ask

How do I save HTML in bokeh?

Bokeh creates the HTML file when you call the show() function. This function also automatically opens a web browser to display the HTML file. If you want Bokeh to only generate the file but not open it in a web browser, use the save() function instead.

Does Bokeh use Matplotlib?

Matplotlib, seaborn, ggplot, and Pandas¶Uses bokeh to display a Matplotlib Figure. You can store a bokeh plot in a standalone HTML file, as a document in a Bokeh plot server, or embedded directly into an IPython Notebook output cell. Parameters: fig (matplotlib.

Is Bokeh a data visualization library?

Bokeh is a Python library for creating interactive visualizations for modern web browsers. It helps you build beautiful graphics, ranging from simple plots to complex dashboards with streaming datasets.


2 Answers

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

like image 89
queise Avatar answered Oct 26 '22 03:10

queise


This 'text' functionality falls under 'glyphs': you'll find the page here

like image 44
user908094 Avatar answered Oct 26 '22 05:10

user908094