bokeh.themes

Provide access to built-in themes:

CALIBER

from bokeh.plotting import figure, output_file, show
from bokeh.themes import built_in_themes
from bokeh.io import curdoc

x = [1, 2, 3, 4, 5]
y = [6, 7, 6, 4, 5]

output_file("caliber.html")
curdoc().theme = 'caliber'
p = figure(title='caliber', plot_width=300, plot_height=300)
p.line(x, y)
show(p)

DARK_MINIMAL

from bokeh.plotting import figure, output_file, show
from bokeh.themes import built_in_themes
from bokeh.io import curdoc

x = [1, 2, 3, 4, 5]
y = [6, 7, 6, 4, 5]

output_file("dark_minimal.html")
curdoc().theme = 'dark_minimal'
p = figure(title='dark_minimal', plot_width=300, plot_height=300)
p.line(x, y)
show(p)

LIGHT_MINIMAL

from bokeh.plotting import figure, output_file, show
from bokeh.themes import built_in_themes
from bokeh.io import curdoc

x = [1, 2, 3, 4, 5]
y = [6, 7, 6, 4, 5]

output_file("light_minimal.html")
curdoc().theme = 'light_minimal'
p = figure(title='light_minimal', plot_width=300, plot_height=300)
p.line(x, y)
show(p)

as well as the Theme class that can be used to create new Themes.

class Theme(filename=None, json=None)[source]

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) then accessing the property with 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 Theme class allows collections of custom default values to be easily applied to Bokeh documents.

The Theme class can be constructed either from a YAML file or from a JSON dict (but not both). The data should have a top level attrs key, followed by

Examples of both formats are shown below.

Parameters
  • filename (str, optional) – path to a YAML theme file

  • json (str, optional) – a JSON dictionary specifying theme values

Raises

ValueError – If neither filename or json is supplied.

Examples

Themes are specified by providing a top-level key attrs which has blocks for Model types to be themed. Each block has keys and values that specify the new property defaults for that type.

Here is an example theme in YAML format that sets various visual properties for all figures, grids, and titles:

attrs:
    Figure:
        background_fill_color: '#2F2F2F'
        border_fill_color: '#2F2F2F'
        outline_line_color: '#444444'
    Grid:
        grid_line_dash: [6, 4]
        grid_line_alpha: .3
    Title:
        text_color: "white"

Here is the same theme, in JSON format:

{
'attrs' : {
    'Figure' : {
        'background_fill_color': '#2F2F2F',
        'border_fill_color': '#2F2F2F',
        'outline_line_color': '#444444',
    },
    'Grid': {
        'grid_line_dash': [6, 4]',
        'grid_line_alpha': .3,
    },
    'Title': {
        'text_color': 'white'
    }
}