bokeh.themes#
Provide access to built-in themes:
Built-in themes#
CALIBER#
from bokeh.plotting import curdoc, figure, show
x = [1, 2, 3, 4, 5]
y = [6, 7, 6, 4, 5]
curdoc().theme = 'caliber'
p = figure(title='caliber', width=300, height=300)
p.line(x, y)
show(p)
CARBON#
from bokeh.plotting import curdoc, figure, show
x = [1, 2, 3, 4, 5]
y = [6, 7, 6, 4, 5]
curdoc().theme = 'carbon'
p = figure(title='carbon', width=300, height=300)
p.line(x, y)
show(p)
DARK_MINIMAL#
from bokeh.plotting import curdoc, figure, show
x = [1, 2, 3, 4, 5]
y = [6, 7, 6, 4, 5]
curdoc().theme = 'dark_minimal'
p = figure(title='dark_minimal', width=300, height=300)
p.line(x, y)
show(p)
LIGHT_MINIMAL#
from bokeh.plotting import curdoc, figure, show
x = [1, 2, 3, 4, 5]
y = [6, 7, 6, 4, 5]
curdoc().theme = 'light_minimal'
p = figure(title='light_minimal', width=300, height=300)
p.line(x, y)
show(p)
NIGHT_SKY#
from bokeh.plotting import curdoc, figure, show
x = [1, 2, 3, 4, 5]
y = [6, 7, 6, 4, 5]
curdoc().theme = 'night_sky'
p = figure(title='night_sky', width=300, height=300)
p.line(x, y)
show(p)
CONTRAST#
from bokeh.plotting import curdoc, figure, show
x = [1, 2, 3, 4, 5]
y = [6, 7, 6, 4, 5]
curdoc().theme = 'contrast'
p = figure(title='contrast', width=300, height=300)
p.line(x, y)
show(p)
Theme#
- class Theme(filename: str | PathLike[str])[source]#
- class Theme(json: dict[str, Any])
- Provide new default values for Bokeh models. - Bokeh Model properties all have some built-in default value. If a property has not been explicitly set (e.g. - m.foo = 10), accessing the property will return the default value. It may be useful for users to be able to specify a different set of default values than the built-in default. The- Themeclass allows collections of custom default values to be easily applied to Bokeh documents.- The - Themeclass can be constructed either from a YAML file or from a JSON dict (but not both). Examples of both formats are shown below.- The plotting API defaults override some theme properties. Namely: fill_alpha, fill_color, line_alpha, line_color, text_alpha and text_color. Those properties should therefore be set explicitly when using the plotting API. - Parameters:
- Raises:
- ValueError – If neither - filenamenor- jsonis supplied.
 - Examples - Themes are specified by providing a top-level key - attrswhich has blocks for Model types to be themed. Each block has keys and values that specify the new property defaults for that type.- Take note of the fact that YAML interprets the value None as a string, which is not usually what you want. To give None as a value in YAML, use !!null. To give ‘None’ as a value in json, use null. - Here is an example theme in YAML format that sets various visual properties for all figures, grids, and titles: - attrs: Plot: background_fill_color: '#2F2F2F' border_fill_color: '#2F2F2F' outline_line_color: '#444444' Axis: axis_line_color: !!null Grid: grid_line_dash: [6, 4] grid_line_alpha: .3 Title: text_color: "white" - Here is the same theme, in JSON format: - { 'attrs' : { 'Plot': { 'background_fill_color': '#2F2F2F', 'border_fill_color': '#2F2F2F', 'outline_line_color': '#444444', }, 'Axis': { 'axis_line_color': None, }, 'Grid': { 'grid_line_dash': [6, 4], 'grid_line_alpha': .3, }, 'Title': { 'text_color': 'white' } } }