pt.grid / | / attachments
Coordinates & layout
Minimal call
import math
xs = [i * 0.2 for i in range(40)]
signal = {"x": xs, "y": [math.sin(x) for x in xs]}
counts = {"cat": ["a", "b", "c"], "n": [4, 7, 3]}
values = {"x": [0.1, 0.4, 0.5, 0.55, 0.7, 0.8, 0.9, 1.1, 1.3]}
a = pt.chart(signal, aes(x="x", y="y"), title="signal",
data_width=200, data_height=130)
a.add_line()
b = pt.chart(counts, aes(x="cat", y="n"), title="counts",
data_width=200, data_height=130)
b.add_bar()
d = pt.chart(values, aes(x="x"), title="dist",
data_width=200, data_height=130)
d.add_hist(bins=6)
c = pt.grid([[a, b], [d, None]])
Docstring
Build a grid-layout `Layout` from a list-of-lists of cells.
Each cell is either a `Chart` or `None` (empty). All rows must have
the same number of columns. The grid does **no proportional
redistribution** — each column's width is the max natural canvas
width across cells in that column; each row's height is the max
natural canvas height across cells in that row. To make a column
twice as wide as another, set `data_width=` directly on the leaf
charts; the grid then sums their natural canvases plus per-boundary
gaps.
The constructor takes only the structural argument (`cells`); all
behavior knobs live on methods so they compose uniformly across
grid-built and `|`/`/`-built layouts. For inter-panel gap, chain
`.gap(N)` for a unified value or `.gap(x=..., y=...)` for per-axis
control. For axis sharing, chain `.share_x("col"/"row"/"all")` /
`.share_y(...)`.