With Bokeh, how to save to a png or jpg instead of a html file?

强颜欢笑 提交于 2019-11-29 09:08:11

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.

OK, correcting to myself, I miss your part about not using the preview/save... Currently we do not provide a direct programmatic way to export Bokeh plots to a png file. You will need the user interaction even using internal functions. We could probably add a feature like that in the feature.

Cheers.

Pete

I asked a similar question yesterday. The linked solution may work for you. Basically you open the file in a web page, take a screen shot which you can then crop and save as an image.

Python open html file, take screenshot, crop and save as image

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!