bokeh.layouts (original) (raw)

Functions for arranging bokeh layout objects.

column#

column(children: list[UIElement], *, sizing_mode: Literal['stretch_width', 'stretch_height', 'stretch_both', 'scale_width', 'scale_height', 'scale_both', 'fixed', 'inherit'] | None = None, **kwargs: Any) → Column[source]#

column(*children: UIElement, sizing_mode: Literal['stretch_width', 'stretch_height', 'stretch_both', 'scale_width', 'scale_height', 'scale_both', 'fixed', 'inherit'] | None = None, **kwargs: Any) → Column

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:

Returns:

A column of LayoutDOM objects all with the same sizing_mode.

Return type:

Column

Examples

column(plot1, plot2) column(children=[widgets, plot], sizing_mode='stretch_both')

grid#

grid(children: list[UIElement | list[UIElement | list[Any]]], *, sizing_mode: Literal['stretch_width', 'stretch_height', 'stretch_both', 'scale_width', 'scale_height', 'scale_both', 'fixed', 'inherit'] | None = None) → GridBox[source]#

grid(children: Row | Column, *, sizing_mode: Literal['stretch_width', 'stretch_height', 'stretch_both', 'scale_width', 'scale_height', 'scale_both', 'fixed', 'inherit'] | None = None) → GridBox

grid(children: list[UIElement | None], *, sizing_mode: Literal['stretch_width', 'stretch_height', 'stretch_both', 'scale_width', 'scale_height', 'scale_both', 'fixed', 'inherit'] | None = None, nrows: int) → GridBox

grid(children: list[UIElement | None], *, sizing_mode: Literal['stretch_width', 'stretch_height', 'stretch_both', 'scale_width', 'scale_height', 'scale_both', 'fixed', 'inherit'] | None = None, ncols: int) → GridBox

grid(children: list[UIElement | None], *, sizing_mode: Literal['stretch_width', 'stretch_height', 'stretch_both', 'scale_width', 'scale_height', 'scale_both', 'fixed', 'inherit'] | None = None, nrows: int, ncols: int) → GridBox

grid(children: str, *, sizing_mode: Literal['stretch_width', 'stretch_height', 'stretch_both', 'scale_width', 'scale_height', 'scale_both', 'fixed', 'inherit'] | None = None) → GridBox

Conveniently create a grid of layoutable objects.

Grids are created by using GridBox model. This gives the most control over the layout of a grid, but is also tedious and may result in unreadable code in practical applications. grid() function remedies this by reducing the level of control, but in turn providing a more convenient API.

Supported patterns:

  1. Nested lists of layoutable objects. Assumes the top-level list represents a column and alternates between rows and columns in subsequent nesting levels. One can use None for padding purpose.

    grid([p1, [[p2, p3], p4]])
    GridBox(children=[
    (p1, 0, 0, 1, 2),
    (p2, 1, 0, 1, 1),
    (p3, 2, 0, 1, 1),
    (p4, 1, 1, 2, 1),
    ])

  2. Nested Row and Column instances. Similar to the first pattern, just instead of using nested lists, it uses nested Row and Column models. This can be much more readable that the former. Note, however, that only models that don’t have sizing_mode set are used.

    grid(column(p1, row(column(p2, p3), p4)))
    GridBox(children=[
    (p1, 0, 0, 1, 2),
    (p2, 1, 0, 1, 1),
    (p3, 2, 0, 1, 1),
    (p4, 1, 1, 2, 1),
    ])

  3. Flat list of layoutable objects. This requires nrows and/or ncols to be set. The input list will be rearranged into a 2D array accordingly. One can use None for padding purpose.

    grid([p1, p2, p3, p4], ncols=2)
    GridBox(children=[
    (p1, 0, 0, 1, 1),
    (p2, 0, 1, 1, 1),
    (p3, 1, 0, 1, 1),
    (p4, 1, 1, 1, 1),
    ])

gridplot#

gridplot(children: list[UIElement | None], *, sizing_mode: Literal['stretch_width', 'stretch_height', 'stretch_both', 'scale_width', 'scale_height', 'scale_both', 'fixed', 'inherit'] | None = None, toolbar_location: Literal['above', 'below', 'left', 'right'] | None = 'above', ncols: int, width: int | None = None, height: int | None = None, toolbar_options: dict[ToolbarOptions, Any] | None = None, merge_tools: bool = True) → GridPlot[source]#

gridplot(children: list[list[UIElement | None]], *, sizing_mode: Literal['stretch_width', 'stretch_height', 'stretch_both', 'scale_width', 'scale_height', 'scale_both', 'fixed', 'inherit'] | None = None, toolbar_location: Literal['above', 'below', 'left', 'right'] | None = 'above', ncols: None = None, width: int | None = None, height: int | None = None, toolbar_options: dict[ToolbarOptions, Any] | None = None, merge_tools: bool = True) → GridPlot

Create a grid of plots rendered on separate canvases.

The gridplot function builds a single toolbar for all the plots in the grid. gridplot is designed to lay out a set of plots. For general grid layout, use the layout() function.

Parameters:

Return type:

GridPlot

Examples

gridplot([[plot_1, plot_2], [plot_3, plot_4]]) gridplot([plot_1, plot_2, plot_3, plot_4], ncols=2, width=200, height=100) gridplot( children=[[plot_1, plot_2], [None, plot_3]], toolbar_location='right' sizing_mode='fixed', toolbar_options=dict(logo='gray') )

layout#

layout(*args: UIElement, children: list[UIElement] | None = None, sizing_mode: Literal['stretch_width', 'stretch_height', 'stretch_both', 'scale_width', 'scale_height', 'scale_both', 'fixed', 'inherit'] | None = None, **kwargs: Any) → Column[source]#

Create a grid-based arrangement of Bokeh Layout objects.

Parameters:

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_1, plot_1], [slider], [widget_2, plot_2, plot_3] ], sizing_mode='fixed', )

row#

row(children: list[UIElement], *, sizing_mode: Literal['stretch_width', 'stretch_height', 'stretch_both', 'scale_width', 'scale_height', 'scale_both', 'fixed', 'inherit'] | None = None, **kwargs: Any) → Row[source]#

row(*children: UIElement, sizing_mode: Literal['stretch_width', 'stretch_height', 'stretch_both', 'scale_width', 'scale_height', 'scale_both', 'fixed', 'inherit'] | None = None, **kwargs: Any) → Row

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:

Returns:

A row of LayoutDOM objects all with the same sizing_mode.

Return type:

Row

Examples

row(plot1, plot2) row(children=[widgets, plot], sizing_mode='stretch_both')

Spacer#

class Spacer(*args: Any, id: ID | None = None, **kwargs: Any)[source]

A container for space used to fill an empty spot in a row or column.