bokeh: 如何以给定尺寸导出网格为png?

问题描述 投票:0回答:1

我准备了一些散景图以html格式显示。

为此,我准备了一个 gridplot 包含子情节、图例和一些标题。这一切在HTML中都显示得非常好,并且有了 sizing_mode='stretch_width' 它甚至有点像响应式的。

webpage = gridplot([[header_col],[panel_grid_plot]], toolbar_location=None, sizing_mode='stretch_width')
show(webpage)

现在我还想把这个 "网页 "导出为PNG。为此,我使用

export_png(webpage, filename= png_filename, width=1800)

遗憾的是 width 参数被忽略,因为 webpage 是一个类型的对象 gridbox 不属 Plot. (这在bokehioexport.py中的方法def中检查。get_layout_html())

输出的是一个宽度为800px的PNG,由于实际信息被压坏了(而图例的比例很好),所以有点无用。enter image description here

有什么办法可以将我的PNG输出的宽度设置为有用的值吗?

有什么办法可以将 gridboxPlot?

Thanx!

bokeh
1个回答
0
投票

你应该已经收到了一个警告,说宽度参数将被忽略,因为你正在向 export_png 不是情节的东西。

一种实现你想要的东西的方式。

webpage = gridplot(..., sizing_mode='stretch_width')
webpage.width = 1800
export_png(webpage)
© www.soinside.com 2019 - 2024. All rights reserved.