散景:如何将网格导出为给定大小的 png?
bokeh: How to export a grid to png with given size?
我准备了一些散景图显示为 html。
为此我准备了一个 gridplot
包含次要情节、图例和一些标题。这一切在 HTML 中显示得非常好,并且在 sizing_mode='stretch_width'
中甚至是响应式的。
webpage = gridplot([[header_col],[panel_grid_plot]], toolbar_location=None, sizing_mode='stretch_width')
show(webpage)
现在我还想将此 "webpage" 导出为 PNG。为此,我使用
export_png(webpage, filename= png_filename, width=1800)
不幸的是,width
参数被忽略,因为 webpage
是 gridbox
类型的 object 而不是 Plot
类型。 (这在方法 def get_layout_html()
中的 bokeh/io/export.py 中检查)
输出是一个宽度为 800px 的 png,这在实际信息被压碎时有点无用(虽然图例已很好地缩放):
关于如何将 PNG 导出的宽度设置为有用值的任何想法?
有没有办法将 gridbox
转换为 Plot
?
谢谢!
您应该收到一条警告,说宽度参数将被忽略,因为您正在传递给 export_png
不是情节的东西。
一种实现你想要的方法:
webpage = gridplot(..., sizing_mode='stretch_width')
webpage.width = 1800
export_png(webpage)
我准备了一些散景图显示为 html。
为此我准备了一个 gridplot
包含次要情节、图例和一些标题。这一切在 HTML 中显示得非常好,并且在 sizing_mode='stretch_width'
中甚至是响应式的。
webpage = gridplot([[header_col],[panel_grid_plot]], toolbar_location=None, sizing_mode='stretch_width')
show(webpage)
现在我还想将此 "webpage" 导出为 PNG。为此,我使用
export_png(webpage, filename= png_filename, width=1800)
不幸的是,width
参数被忽略,因为 webpage
是 gridbox
类型的 object 而不是 Plot
类型。 (这在方法 def get_layout_html()
中的 bokeh/io/export.py 中检查)
输出是一个宽度为 800px 的 png,这在实际信息被压碎时有点无用(虽然图例已很好地缩放):
关于如何将 PNG 导出的宽度设置为有用值的任何想法?
有没有办法将 gridbox
转换为 Plot
?
谢谢!
您应该收到一条警告,说宽度参数将被忽略,因为您正在传递给 export_png
不是情节的东西。
一种实现你想要的方法:
webpage = gridplot(..., sizing_mode='stretch_width')
webpage.width = 1800
export_png(webpage)