bokeh.layouts

Functions for arranging bokeh Layout objects.

class GridSpec(nrows, ncols)

Simplifies grid layout specification.

column(*args, **kwargs)

Create a column of Bokeh Layout objects. Forces all objects to have the same sizing_mode, which is required for complex layouts to work.

Parameters:
  • children (list of LayoutDOM) – A list of instances for the column. Can be any of the following - Plot, Widget, WidgetBox, Row, Column, ToolbarBox, Spacer.
  • sizing_mode ("fixed", "stretch_both", "scale_width", "scale_height", "scale_both") – How will the items in the layout resize to fill the available space. Default is "fixed". For more information on the different modes see sizing_mode description on LayoutDOM.
  • responsive (True, False) – "width_ar". False sets sizing_mode to "fixed". Using responsive will override sizing_mode.
Returns:

A column of LayoutDOM objects all with the same sizing_mode.

Return type:

Column

Examples

>>> column([plot_1, plot_2])
>>> column(children=[widget_box_1, plot_1], sizing_mode='stretch_both')
gridplot(*args, **kwargs)

Create a grid of plots rendered on separate canvases. gridplot builds a single toolbar for all the plots in the grid. gridplot is designed to layout a set of plots. For general grid layout, use the layout() function.

Parameters:
  • children (list of lists of Plot) – An array of plots to display in a grid, given as a list of lists of Plot objects. To leave a position in the grid empty, pass None for that position in the children list. OR list of Plot if called with ncols. OR an instance of GridSpec.
  • sizing_mode ("fixed", "stretch_both", "scale_width", "scale_height", "scale_both") – How will the items in the layout resize to fill the available space. Default is "fixed". For more information on the different modes see sizing_mode description on LayoutDOM.
  • toolbar_location (above, below, left, right) – Where the toolbar will be located, with respect to the grid. Default is above. If set to None, no toolbar will be attached to the grid.
  • Int (ncols) – Specify the number of columns you would like in your grid. You must only pass an un-nested list of plots (as opposed to a list of lists of plots) when using ncols.
  • responsive (True, False) – "width_ar". False sets sizing_mode to "fixed". Using responsive will override sizing_mode.
  • plot_width (int, optional) – The width you would like all your plots to be
  • plot_height (int, optional) – The height you would like all your plots to be.
  • toolbar_options (dict, optional) – A dictionary of options that will be used to construct the grid’s toolbar (an instance of ToolbarBox). If none is supplied, ToolbarBox’s defaults will be used.
  • merge_tools (True, False) – Combine tools from all child plots into a single toolbar.
Returns:

A row or column containing the grid toolbar and the grid

of plots (depending on whether the toolbar is left/right or above/below. The grid is always a Column of Rows of plots.

Return type:

Row or Column

Examples

>>> gridplot([[plot_1, plot_2], [plot_3, plot_4]])
>>> gridplot([plot_1, plot_2, plot_3, plot_4], ncols=2, plot_width=200, plot_height=100)
>>> gridplot(
        children=[[plot_1, plot_2], [None, plot_3]],
        toolbar_location='right'
        sizing_mode='fixed',
        toolbar_options=dict(logo='gray')
    )
layout(*args, **kwargs)

Create a grid-based arrangement of Bokeh Layout objects. Forces all objects to have the same sizing mode, which is required for complex layouts to work. Returns a nested set of Rows and Columns.

Parameters:
  • children (list of lists of LayoutDOM) – A list of lists of instances for a grid layout. Can be any of the following - Plot, Widget, WidgetBox, Row, Column, ToolbarBox, Spacer.
  • sizing_mode ("fixed", "stretch_both", "scale_width", "scale_height", "scale_both") – How will the items in the layout resize to fill the available space. Default is "fixed". For more information on the different modes see sizing_mode description on LayoutDOM.
  • responsive (True, False) – "width_ar". False sets sizing_mode to "fixed". Using responsive will override sizing_mode.
Returns:

A column of Row layouts of the children, all with the same sizing_mode.

Return type:

Column

Examples

>>> layout([[plot_1, plot_2], [plot_3, plot_4]])
>>> layout(
        children=[
            [widget_box_1, plot_1],
            [slider],
            [widget_box_2, plot_2, plot_3]
        ],
        sizing_mode='fixed',
    )
row(*args, **kwargs)

Create a row of Bokeh Layout objects. Forces all objects to have the same sizing_mode, which is required for complex layouts to work.

Parameters:
  • children (list of LayoutDOM) – A list of instances for the row. Can be any of the following - Plot, Widget, WidgetBox, Row, Column, ToolbarBox, Spacer.
  • sizing_mode ("fixed", "stretch_both", "scale_width", "scale_height", "scale_both") – How will the items in the layout resize to fill the available space. Default is "fixed". For more information on the different modes see sizing_mode description on LayoutDOM.
  • responsive (True, False) – "width_ar". False sets sizing_mode to "fixed". Using responsive will override sizing_mode.
Returns:

A row of LayoutDOM objects all with the same sizing_mode.

Return type:

Row

Examples

>>> row([plot_1, plot_2])
>>> row(children=[widget_box_1, plot_1], sizing_mode='stretch_both')
widgetbox(*args, **kwargs)

Create a WidgetBox of Bokeh widgets. Forces all to have the same sizing_mode, which is required for complex layouts to work.

Parameters:
  • children (list of Widget) – A list
  • widgets for the WidgetBox. (of) –
  • sizing_mode ("fixed", "stretch_both", "scale_width", "scale_height", "scale_both") – How will the items in the layout resize to fill the available space. Default is "fixed". For more information on the different modes see sizing_mode description on LayoutDOM.
  • responsive (True, False) – "width_ar". False sets sizing_mode to "fixed". Using responsive will override sizing_mode.
Returns:

A WidgetBox of Widget instances all with the same sizing_mode.

Return type:

WidgetBox

Examples

>>> widgetbox([button, select])
>>> widgetbox(children=[slider], sizing_mode='scale_width')