I need to export pictures of the graphs and plots I am creating with Bokeh.
Usually I do
output_file("test.html")
However, I want to copy that graph into an Excel Sheet. It does not have to be interactive anymore, though that would be brillant. How do I export the graph as a picture? Using code, not clicking on "preview/save".
Exporting PNG images Bokeh can generate RGBA-format Portable Network Graphics (PNG) images from layouts using the export_png() function. This functionality renders the layout in memory and then captures a screenshot. The output image will have the same dimensions as the source layout.
Bokeh creates the HTML file when you call the show() function. This function also automatically opens a web browser to display the HTML file. If you want Bokeh to only generate the file but not open it in a web browser, use the save() function instead.
You can run and list as many Bokeh servers as you need. To run a Bokeh server instance, use commands similar to the following: serve myapp.py --port 5100 serve myapp.py --port 5101 ... Next, in the location stanza for the Bokeh server, change the proxy_pass value to refer to the upstream stanza above.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With