Skillversitas

Layouts

Layouts compose multiple plots (and other layoutables) into a single document: row, column, gridplot, and the older spread. They are how you build dashboards - several coordinated charts in one HTML page or server app.

row and column

from bokeh.plotting import figure, show
from bokeh.layouts import row, column

p1 = figure(width=300, height=200, title="Chart 1")
p1.circle([1, 2, 3], [1, 2, 3])

p2 = figure(width=300, height=200, title="Chart 2")
p2.square([1, 2, 3], [3, 2, 1])

p3 = figure(width=600, height=200, title="Wide chart")
p3.line([1, 2, 3, 4], [4, 3, 5, 2])

layout = column(row(p1, p2), p3)
show(layout)

gridplot for 2D Arrangements

from bokeh.layouts import gridplot

layout = gridplot([[p1, p2],
                   [p3, p4]],
                  toolbar_location="right",
                  sizing_mode="fixed")

gridplot takes a nested list of layoutables; None entries leave a cell empty.

Sizing Modes

from bokeh.models import SizingMode

# responsive: plots resize with the browser
layout = column(row(p1, p2), sizing_mode=SizingMode.WIDTH_CONTROLS_HEIGHT)
# or per plot:
p1.sizing_mode = "width"

Shared Toolbars

# merge the toolbars of the subplots into one, on the right:
layout = gridplot([[p1, p2], [p3, p4]], toolbar_location="right")
# reset all toolbars to their default positions:
layout = gridplot([[p1, p2]], toolbar_location="default")

Labels and Spacing

from bokeh.models import Div

header = Div(text='''<h2>Sales Dashboard</h2>''', width=600)
layout = column(header, row(p1, p2), height=500)

Summary

Compose Bokeh dashboards with row, column, and gridplot: nest plots for 1D and 2D arrangements, control responsiveness with sizing_mode, consolidate toolbars with toolbar_location, and add titles or headers with Div widgets. The layout object is itself showable, so a whole dashboard is one show() call.