How to set Bokeh legend font?

I tried the proposed:

p.legend().label_text_font = "times"

but I got an error:

TypeError: '_list_attr_splat' object is not callable

however it worked fine when I left out the parentheses:

p.legend.label_text_font = "times"

If label_text_font is not what you want, you can often get a list of the available attributes for legend, or another 'list_attr_splat' object, by inducing the super helpful error message:

p.legend.blah = "foo"

AttributeError: unexpected attribute 'blah' to Legend, 
possible attributes are border_line_alpha, border_line_cap,
border_line_color, border_line_dash, border_line_dash_offset, 
border_line_join, border_line_width, glyph_height, glyph_width,
label_height, label_standoff, label_text_align, label_text_alpha,
label_text_baseline, label_text_color, label_text_font,
label_text_font_size, label_text_font_style, label_width, 
legend_padding, legend_spacing, legends, name, orientation, 
plot, session or tags

You need to get ahold of the Legend object(s) of the current plot which can be done with legend plot attribute and then set the label_text_font property:

plot.legend.label_text_font = "times"

note these property names may be shortened/simplified in the near future.


extra information for those who reach this page while searching on "how to move the legend to another corner?":

legend().orientation = "top_left"

acceptables terms top_left, top_right, bottom_left and bottom_right.

Tags:

Python

Bokeh