Exporting figures from Bokeh as svg or pdf?

bokeh, python

Solution

There is no way to save PDF currently, but as of Bokeh `0.12.6`, it is now possible to export PNG and SVG directly from Python code.

Exporting PNGs looks like this

export_png(plot, filename="plot.png")

And exporting SVGs looks like this

plot.output_backend = "svg"
export_svgs(plot, filename="plot.svg")

There are some optional dependencies that need to be installed. You can find more information in the Exporting Plots section of the User Guide.

Problem

Is it possible to output individual figures from Bokeh as pdf or svg images? I feel like I'm missing something obvious, but I've checked the online help pages and gone through the `bokeh.objects` api and haven't found anything...

Original source