18
votes

How do I set the title font size for a figure when using bokeh?

I tried (in ipython notebook):

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', \
    text_font_size='8pt')

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

I've tried text_font_size, label_text_font, title_font_size, etc. Where in the documentation is all of this information?

2

2 Answers

29
votes

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"
12
votes

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()