python - 使用 Bokeh,如何保存为 png 或 jpg 而不是 html 文件?

标签 python bokeh

我需要导出使用 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/

相关文章:

python - 聚合 Pandas 数据框

python - 将 PyInstaller 与 Bokeh 和 CustomJS 结合使用

bokeh - 用 Bokeh 显示 jpg 的最有效方式? Image_rgba 出奇的慢

python - 如何使 Bokeh 工具提示中的文本正确换行?

python - 无法增加 Bokeh 中整个图表的大小并使图表处于水平轴

python - 从所有其他行中减去每一行并在 python 中查看为矩阵

python - 如何在 word 文档中创建书签,然后使用 python 创建指向书签的内部超链接

python - 如何让 Flake8 处理 F811 错误?

python - 使用 python 添加两个自定义数据类型?

javascript - Bokeh 单击按钮使用 javascript 将小部件值保存到 txt 文件