Leveraging Other Libraries

Overview

Bokeh currently utilizes the third party library mplexporter to help convert Matplotlib plots into Bokeh plots. MPL plots using features not supported by mplexporter may not render fully. However, there are plans (MEP 25) for Matplotlib to adopt a native JSON ingest/export functionality of its own in the future. This will allow Bokeh and other systems to interact more robustly with Matplotlib.

Current MPL compatibility also is sufficient to render many instances of Seaborn and ggplot.py code. Additionally you can easily render plots generated by Pandas as well. To display any of these plots, pass them to the bokeh.mpl.to_bokeh function:


to_bokeh(fig=None, use_pandas=True, xkcd=False)

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.

You can see examples of Bokeh rendering plots from all of these libraries in the examples/compat directory. This link points to master, don’t forget to make sure you’re looking at examples that match with the version of bokeh you’re using.