Settings, Theming & Backends
Bokeh.settings! — Functionsettings!(key=value, ...)Update the global settings for Bokeh.
display: The display backend to use, such as"browser"or"blink". Default:"null".offline: If set totruethen any generated plots will work offline. Default:false.browser_cmd: The command used to open the browser. Default: Operating-system dependent.theme: TheThemeto apply when displaying plots. May instead be the name of a builtin theme or a JSON or YAML file. Default:"default".
Theming
The appearance of a Bokeh plot comes from these sources, in order of precedence:
- A plot-specific theme, given by creating a
Documentwith the specified theme. - A global theme, given as the
themeargument toBokeh.settings!. - The display backend.
- Bokeh defaults.
Bokeh.Theme — TypeTheme(source)Construct a theme from the given source, which is either:
- The name of a builtin theme.
- The name of a JSON or YAML file.
- An iterator of the form
[type => [attr => value, ...], ...].
For example, here is a theme which overrides some attributes on all figures, axes, grids and titles:
Theme([
"Figure" => [
"background_fill_color" => "#2F2F2F",
"border_fill_color" => "#2F2F2F",
"outline_line_color" => "#444444",
],
"Axis" => [
"axis_line_color" => nothing,
],
"Grid" => [
"grid_line_dash" => [6, 4],
"grid_line_alpha" => 0.3,
],
"Title" => [
"text_color" => "white",
],
])You can apply a theme globally using Bokeh.settings! or on a particular plot by wrapping it into a Document.
Bokeh.theme! — Functiontheme!([theme], "Type.attr" => value, ...)Modify the theme with the given key-value pairs.
If theme is not given, the default theme is modified.
For example, here we change the default height and width of all plots:
Bokeh.theme!("Plot.width"=>1000, "Plot.height"=>800)Bokeh.load_theme — Functionload_theme(filename)Load a theme from the given file.
The format (JSON or YAML) is deduced from the file name.
Bokeh.save_theme — Functionsave_theme(filename, [theme])Save the given theme to the given file.
If theme is not given, the default theme is saved.
The format (JSON or YAML) is deduced from the file name.
Bokeh.Document — TypeDocument(plot; [theme])Construct a new document to render the given plot.
The given theme (a Theme) is used to override attributes of the plot. It takes precedence over the global theme set using Bokeh.settings!.
Display Backends
Plots can automatically be displayed anywhere supporting HTML output, such as a Pluto or Jupyter notebook. Anywhere else, such as the Julia REPL, will require a display backend to be activated.
Browser
To display plots in your default browser, set
Bokeh.settings!(display="browser")Blink
The BokehBlink package can be separately installed to enable plotting into a standalone Blink.jl window.
To activate this backend, do
using Bokeh, BokehBlink
Bokeh.settings!(display="blink")By default, plots are stretched to fill the window. You may override this by setting sizing_mode on the top-level figure/column/row/etc.
This package can also be used to export plots as images. You do not need to activate the backend first.
BokehBlink.save — Functionsave(io, [plot]; ...)
save(filename, [plot]; ...)Save a screenshot of the current plot or the given plot.
Keyword Arguments
format: The output format to use. Valid formats include"png","jpeg"and"webp". Iffilenameis given, the format is inferred from the extension. Otherwise it defaults to"png".quality: A number between 0 and 1 specifying the quality (compression level) of the image.
This is an experimental feature and likely to be buggy, particularly the version taking a plot argument.
Null
The null backend cannot display anything. It is the default backend. Use it to deactivate another backend:
Bokeh.settings!(display="null")Interactive Backends
🚧 Coming soon! 🚧