Is there a simple way to automatically fit a Bokeh plot to the screen used to display your browser? Right now I'm setting the plot width and height manually.
Note: when I say fit I mean that I want the plot to fill 80% of the visible screen.
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.