plot_text horizontal and vertical alignment equivalent in bokeh

Question:

Is there an equivalent of matplotlib’s ha and va (horizontal and vertical alignment) when plotting text in bokeh?

In matplotlib I would write something like the following:

plt.text(x, y, 'text', ha='center', va='bottom')

In bokeh I am plotting text using the following method:

glyph = Text(x="x", y="y", text="text")
stagger_data.add_glyph(source, glyph)

Where source is a ColumnDataSource object.

Many thanks.

Asked By: tomp

||

Answers:

I think you can use the text_align and the text_baseline attributes of the Text glyph.

glyph = Text(x="x", y="y", text="text", text_align="center",text_baseline="bottom")

You can have a look here in the documentation to see all the available fields in the creation of a Text glyph.

Answered By: robinood
Categories: questions Tags: , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.