Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

plot_text horizontal and vertical alignment equivalent in bokeh

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:

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

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

Where source is a ColumnDataSource object.

Many thanks.

>Solution :

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.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading