Home > Net >  plot_text horizontal and vertical alignment equivalent in bokeh
plot_text horizontal and vertical alignment equivalent in bokeh

Time:10-18

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.

CodePudding user response:

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.

  • Related