Automatically fit Bokeh plot to screen?

有些话、适合烂在心里 提交于 2019-12-05 02:29:24

In more recent bokeh versions, yes you can do this (easily).

plots and layouts now have a sizing_mode property which by default is set to fixed. The other values include scale_width, scale_height, and scale_both.

import bokeh.plotting
import bokeh.layouts

fig1 = bokeh.plotting.figure()
fig1.sizing_mode = 'scale_width'

fig2 = bokeh.plotting.figure()
fig2.sizing_mode = 'scale_width'

column = bokeh.layouts.column([fig1, fig2])
column.sizing_mode = 'scale_width'

As in the example above, your layout will need to have its sizing_mode attribute set appropriately to let its children plots expand.

Using the above example your plot will expand to the size of its container. It's up to you to appropriately size the container (using CSS) to suit your needs.

Note that the width/height property of your figures/plots still matter: they determine the ratio at which the bokeh layout scales.

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