我需要导出使用 Bokeh 创建的图形和绘图的图片。
我经常这样做
output_file("test.html")
但是,我想将该图表复制到 Excel 工作表中。 它不再必须是交互式的,尽管那会很棒。 如何将图表导出为图片?使用代码,而不是点击“预览/保存”。
最佳答案
从 Bokeh 0.12.6
开始,现在可以直接从
Python 代码。
导出 PNG 看起来像这样
export_png(plot, filename="plot.png")
导出 SVG 看起来像这样
plot.output_backend = "svg"
export_svgs(plot, filename="plot.svg")
有一些可选的依赖项需要安装。 您可以在 Exporting Plots section of the User Guide 中找到更多信息.
关于python - 使用 Bokeh,如何保存为 png 或 jpg 而不是 html 文件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24060173/