Leveraging Other Libraries

Bokeh integrates well with a wide variety of other libraries, allowing you to use the most appropriate tool for each task.

JavaScript

Bokeh generates JavaScript, and so Bokeh output can be combined with a wide variety of JavaScript libraries, such as PhosphorJS. Listing such libraries is beyond the scope of this document; it’s best just to try and see!

HoloViews

HoloViews is a separately maintained package that provides a concise declarative interface for building Bokeh plots. HoloViews is particularly focused on interactive use in a Jupyter notebook, allowing quick prototyping of figures for data analysis. For instance, to build an interactive figure with three linked Bokeh plots requires only one line of code in HoloViews:

HoloViews Bokeh example

Adding overlaid plots, slider widgets, selector widgets, selection tools, and tabs is similarly straightforward. HoloViews objects can also be rendered using a Matplotlib-based backend, which allows SVG or PDF output not currently available for native Bokeh plots. See the Holoviews Bokeh_Backend tutorial for more details.

Matplotlib, seaborn, ggplot, and Pandas

Bokeh can display figures created using Matplotlib, which allows you to combine Matplotlib and Bokeh plots in the same document. Because Seaborn, ggplot.py, and Pandas generate Matplotlib figures, in many cases you can also use output from each of these packages. To display one of these plots, pass it to the bokeh.mpl.to_bokeh function:


to_bokeh(fig=None, tools='pan, wheel_zoom, box_zoom, save, reset, help', use_pandas=True, xkcd=False)[source]

Uses bokeh to display a Matplotlib Figure.

You can store a bokeh plot in a standalone HTML file, as a document in a Bokeh plot server, or embedded directly into an IPython Notebook output cell.

Parameters:
  • fig (matplotlib.figure.Figure) – The figure to display. If None or not specified, then the current figure will be used.
  • use_pandas (bool (default=True)) – The implementation should try to use Pandas for processing datetime data (if it is installed). Set to False to plot the datetime xaxis with other non-pandas interfaces.
  • xkcd (bool (default=False)) – If this option is True, then the Bokeh figure will be saved with a xkcd style.

To achieve this interoperability, Bokeh currently relies on the third-party library mplexporter, which can convert many Matplotlib plots into Bokeh plots. However, MPL plots using features not supported by mplexporter may not render fully.

Interoperability with these libraries is expected to improve significantly in the future, based on plans (MEP 25) for Matplotlib to adopt a native JSON ingest/export functionality of its own. This will allow Bokeh and other systems to interact more robustly with Matplotlib, potentially in both directions (i.e., with Matplotlib able to display Bokeh plots).

You can see examples of Bokeh rendering Matplotlib plots generated from each of these libraries in the examples/compat directory.