Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Adjust title font size for a Bokeh figure

Tags:

python

bokeh

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?

like image 588
dmb Avatar asked Dec 10 '14 16:12

dmb


People also ask

How do I get rid of gridlines in bokeh?

You can hide the lines by setting their grid_line_color to None .


2 Answers

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"
like image 141
joon Avatar answered Oct 01 '22 04:10

joon


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()
like image 39
dmb Avatar answered Oct 01 '22 02:10

dmb