Functions for configuring Bokeh output.


Return the document for the current default state.

Returns:the current default document object.
Return type:doc

Return the current State object

Returns:the current default State object
Return type:state
output_file(filename, title='Bokeh Plot', mode='cdn', root_dir=None)[source]

Configure the default output state to generate output saved to a file when show() is called.

Does not change the current Document from curdoc(). File and notebook output may be active at the same time, so e.g., this does not clear the effects of output_notebook().

  • filename (str) – a filename for saving the HTML document
  • title (str, optional) – a title for the HTML document (default: “Bokeh Plot”)
  • mode (str, optional) – how to include BokehJS (default: 'cdn') One of: 'inline', 'cdn', 'relative(-dev)' or 'absolute(-dev)'. See bokeh.resources.Resources for more details.
  • root_dir (str, optional) – root directory to use for ‘absolute’ resources. (default: None) This value is ignored for other resource types, e.g. INLINE or CDN.



Generally, this should be called at the beginning of an interactive session or the top of a script.


This output file will be overwritten on every save, e.g., each time show() or save() is invoked.

output_notebook(resources=None, verbose=False, hide_banner=False, load_timeout=5000)[source]

Configure the default output state to generate output in Jupyter notebook cells when show() is called.

  • resources (Resource, optional) – How and where to load BokehJS from (default: CDN)
  • verbose (bool, optional) – whether to display detailed BokehJS banner (default: False)
  • hide_banner (bool, optional) – whether to hide the Bokeh banner (default: False)
  • load_timeout (int, optional) – Timeout in milliseconds when plots assume load timed out (default: 5000)



Generally, this should be called at the beginning of an interactive session or the top of a script.

push_notebook(document=None, state=None, handle=None)[source]

Update Bokeh plots in a Jupyter notebook output cells with new data or property values.

When working the the notebook, the show function can be passed the argument notebook_handle=True, which will cause it to return a handle object that can be used to update the Bokeh output later. When push_notebook is called, any property updates (e.g. plot titles or data source values, etc.) since the last call to push_notebook or the original show call are applied to the Bokeh output in the previously rendered Jupyter output cell.

Several example notebooks can be found in the GitHub repository in the examples/howto/notebook_comms directory.

  • document (Document, optional) – A Document to push from. If None, uses curdoc().
  • state (State, optional) – A Bokeh State object



Typical usage is typically similar to this:

from bokeh.plotting import figure
from import output_notebook, push_notebook, show


plot = figure()[1,2,3], [4,6,5])

handle = show(plot, notebook_handle=True)

# Update the plot title in the earlier cell
plot.title = "New Title"

Clear the default state of all output modes.

save(obj, filename=None, resources=None, title=None, state=None, **kwargs)[source]

Save an HTML file with the data for the current document.

Will fall back to the default output state (or an explicitly provided State object) for filename, resources, or title if they are not provided. If the filename is not given and not provided via output state, it is derived from the script name (e.g. /foo/ will create /foo/myplot.html)

  • obj (LayoutDOM object) – a Layout (Row/Column), Plot or Widget object to display
  • filename (str, optional) – filename to save document under (default: None) If None, use the default state configuration.
  • resources (Resources, optional) – A Resources config to use (default: None) If None, use the default state configuration, if there is one. otherwise use resources.INLINE.
  • title (str, optional) – a title for the HTML document (default: None) If None, use the default state title value, if there is one. Otherwise, use “Bokeh Plot”

the filename where the HTML file is saved.

Return type:

filename (str)


Configure the current document (returned by curdoc()).

Parameters:doc (Document) – Document we will output.


Calling this function will replace any existing document.

show(obj, browser=None, new='tab', notebook_handle=False, notebook_url='localhost:8888')[source]

Immediately display a Bokeh object or application.

  • obj (LayoutDOM or Application) –

    A Bokeh object to display.

    Bokeh plots, widgets, layouts (i.e. rows and columns) may be passed to show in order to display them. When output_file has been called, the output will be to an HTML file, which is also opened in a new browser window or tab. When output_notebook has been called in a Jupyter notebook, the output will be inline in the associated notebook output cell.

    In a Jupyter notebook, a Bokeh application may also be passed. The application will be run and displayed inline in the associated notebook output cell.

  • browser (str, optional) –

    Specify the browser to use to open output files(default: None)

    For file output, the browser argument allows for specifying which browser to display in, e.g. “safari”, “firefox”, “opera”, “windows-default”. Not all platforms may support this option, see the documentation for the standard library webbrowser module for more information

  • new (str, optional) –

    Specify the browser mode to use for output files (default: “tab”)

    For file output, opens or raises the browser window showing the current output file. If new is ‘tab’, then opens a new tab. If new is ‘window’, then opens a new window.

  • notebook_handle (bool, optional) –

    Whether to create a notebook interaction handle (default: False)

    For notebook output, toggles whether a handle which can be used with push_notebook is returned. Note that notebook handles only apply to standalone plots, layouts, etc. They do not apply when showing Applications in the notebook.

  • notebook_url (URL, optional) –

    Location of the Jupyter notebook page (default: “localhost:8888”)

    When showing Bokeh applications, the Bokeh server must be explicitly configured to allow connections originating from different URLs. This parameter defaults to the standard notebook host and port. If you are running on a differnet location, you will need to supply this value for the application to display properly.

    It is also possible to pass notebook_url="*" to disable the standard checks, so that applications will display regardless of the current notebook location, however a warning will appear.

Some parameters are only useful when certain output modes are active:

  • The browser and new parameters only apply when output_file is active.
  • The notebook_handle parameter only applies when output_notebook is active, and non-Application objects are being shown.
  • The notebook_url parameter only applies when showing Bokeh Applications in a Jupyter notebook.
Returns:When in a Jupyter notebook (with output_notebook enabled) and notebook_handle=True, returns a handle that can be used by push_notebook, None otherwise.