How do you change size of labels in the Bokeh legend in python?

You can view the source code on GitHub

The only search hit for 'label_text_font_size' is in this file:-

 bokeh/bokehjs/src/coffee/renderer/annotation/legend.coffee

and scroll down to the Legend class (line 113 at the time of writing this) then you can see the class attributes. Currently they are:-

 display_defaults: ->
return _.extend {}, super(), {
level: 'overlay'
border_line_color: 'black'
border_line_width: 1
border_line_alpha: 1.0
border_line_join: 'miter'
border_line_cap: 'butt'
border_line_dash: []
border_line_dash_offset: 0
label_standoff: 15
label_text_font: "helvetica"
label_text_font_size: "10pt"
label_text_font_style: "normal"
label_text_color: "#444444"
label_text_alpha: 1.0
label_text_align: "left"
label_text_baseline: "middle"
glyph_height: 20
glyph_width: 20
label_height: 20
label_width: 50
legend_padding: 10
legend_spacing: 3
orientation: "top_right"
datapoint: null
}

.. none of them stand out as being the property that you want, so it might not be possible to change it but you might like to have a play?

NB I don't think all the properties have setters so you may have to set them using something like this: p.legend.__setattr__('label_text_color', "#FF0000")

NB Bokeh is written in CoffeeScript which I have no experience of so this may all be useless.


The following (as proposed by @ciornav) works for me in bokeh 0.13.0:

p.legend.label_text_font_size = '20pt'

as documented here.

Be careful though where you put this code. When it's e.g. between your p.figure() and p.line() statements, it will not take effect as it seems to get overridden.

Put the code after all the artifacts have been created, before p.show() or p.save().