Functions for arranging bokeh layout objects.
GridSpec
Simplifies grid layout specification.
Spacer
Bases: bokeh.models.layouts.LayoutDOM
bokeh.models.layouts.LayoutDOM
A container for space used to fill an empty spot in a row or column.
{ "align": "start", "aspect_ratio": null, "background": null, "css_classes": [], "disabled": false, "height": null, "height_policy": "auto", "id": "9306", "js_event_callbacks": {}, "js_property_callbacks": {}, "margin": [ 0, 0, 0, 0 ], "max_height": null, "max_width": null, "min_height": null, "min_width": null, "name": null, "sizing_mode": null, "subscribed_events": [], "tags": [], "visible": true, "width": null, "width_policy": "auto" }
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.
children (list of LayoutDOM) – A list of instances for the column. Can be any of the following - Plot, Widget, Row, Column, ToolbarBox, Spacer.
LayoutDOM
Plot
Widget
Row
Column
ToolbarBox
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.
"fixed"
"stretch_both"
"scale_width"
"scale_height"
"scale_both"
sizing_mode
A column of LayoutDOM objects all with the same sizing_mode.
Examples
>>> column(plot1, plot2) >>> column(children=[widgets, plot], sizing_mode='stretch_both')
grid
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.
GridBox
grid()
Supported patterns:
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.
None
>>> 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), ])
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), ])
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.
nrows
ncols
>>> 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
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 layout a set of plots. For general grid layout, use the layout() function.
layout()
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.
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.
above
below
left
right
ncols (int, optional) – 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.
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.
True
False
of plots (depending on whether the toolbar is left/right or above/below. The grid is always a Column of Rows of plots.
Row or Column
>>> 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
Create a grid-based arrangement of Bokeh Layout objects.
children (list of lists of LayoutDOM) – A list of lists of instances for a grid layout. Can be any of the following - Plot, Widget, Row, Column, ToolbarBox, Spacer.
A column of Row layouts of the children, all with the same sizing_mode.
>>> 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
Create a row of Bokeh Layout objects. Forces all objects to have the same sizing_mode, which is required for complex layouts to work.
children (list of LayoutDOM) – A list of instances for the row. Can be any of the following - Plot, Widget, Row, Column, ToolbarBox, Spacer.
A row of LayoutDOM objects all with the same sizing_mode.
>>> row(plot1, plot2) >>> row(children=[widgets, plot], sizing_mode='stretch_both')
widgetbox
Create a column of bokeh widgets with predefined styling.
children (list of Widget) – A list of widgets.
A column layout of widget instances all with the same sizing_mode.
WidgetBox
>>> widgetbox([button, select]) >>> widgetbox(children=[slider], sizing_mode='scale_width')