Adjust title font size for a Bokeh figure

I figured it out. You need to prepend 'title_' to 'text_font_size'

import bokeh.plotting as bp
import numpy as np
bp.output_notebook()

x_points = np.random.rand(100)
y_points = np.random.rand(100)

bp.figure(title='My Title', x_axis_label='X axis', y_axis_label='Y axis', \
    title_text_font_size='8pt')

bp.scatter(x_points, y_points)
bp.show()

Plot property title_text_font_size was deprecated in 0.12.0 and will be removed. As of bokeh version 0.12.0, one should use Plot.title.text_font_size instead. Updated example is below:

import numpy as np
import bokeh.plotting as bp

bp.output_notebook()

x_points = np.random.rand(100)
y_points = np.random.rand(100)

p = bp.figure(title='My Title', x_axis_label='X axis', y_axis_label='Y axis')

p.title.text_font_size = '8pt'

p.scatter(x_points, y_points)
bp.show(p)

You can change the font size of axis labels similarly:

p.xaxis.axis_label_text_font_size = "20pt"
p.yaxis.axis_label_text_font_size = "20pt"

Tags:

Python

Bokeh