☰Read-only archive⌕
Looking for help with Bokeh?

This is a read-only archive. Ask questions and join the conversation on GitHub.

Visit Community Support on GitHub →
Archived discussions · Captured October 28, 2026

Setting legend location in BokehJS

Community Support
Joshua_Adelman
Joshua_Adelman

As an experiment, I’m trying to convert a figure that was originally written with the python interface to Bokeh to directly use BokehJS in the browser. While much of the conversion has been straightforward and amounts to turning keyword arguments into json objects, I cannot seem to figure out from looking at examples or consulting the source code how to set the position of the legend.

If I have a figure that I’ve defined using:

let p = plt.figure({tools: tools, x_axis_type: ‘datetime’,
plot_width: plot_width, plot_height: plot_height, sizing_mode: ‘scale_width’,
background_fill_color: bg_fill});

``

if I then try:

p.legend.location = ‘top_left’;
p.legend.click_policy=“hide”;

``

I get the error “TypeError: p.legend is undefined”. Also, what would be the javascript equivalent of the following python snippet?

p.yaxis[0].formatter = bokeh.models.NumeralTickFormatter(format="$0")

``

Thanks,

Josh

⌁   Link to post

End of archived discussion · Replies are disabled