Insert plot from bokeh in the documentationΒΆ

2015-04-12

As graphs from matplotlib, graphs from bokeh can be inserted in the documentation with the extension bokeh.sphinxext.bokeh_plot.

I replicate here the example from the documentation:

.. bokeh-plot::

    from bokeh.plotting import figure, output_file, show

    output_file("example_bokeh.html")

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

    p = figure(title="example_bokeh", plot_width=300, plot_height=300)
    p.line(x, y, line_width=2)
    p.circle(x, y, size=10, fill_color="white")

    show(p)

See example with bokeh to se the result. Including this code in the blog post fails but it should be fixed some days.

Last detail, for some reasons I don’t know, the instruction output_file must remain. I tried different version with different title and file name but it did not work either. You should look into bokeh’s documentation to get a better sense of how it works as this macro is used to generate the documentation of the module.